Re: HTOD

2017-08-23 Thread Timothee Cour via Digitalmars-d
On Wed, Aug 23, 2017 at 10:38 PM, lobo via Digitalmars-d
 wrote:
> On Thursday, 24 August 2017 at 01:51:25 UTC, Timothee Cour wrote:
>>>
>>> [...]
>>
>>
>> nim:
>> it supports both targetting C++ (as well as C or javascript) and also
>> calling C++ via foreign function interface, eg here are some links:
>> https://github.com/nim-lang/Nim/wiki/Playing-with-CPP--VTABLE-from-Nim
>>
>> https://stackoverflow.com/questions/29526958/wrapping-nested-templated-types-in-nim
>> https://forum.nim-lang.org/t/1056
>>
>> for D, there's a project to support full C++ natively using clang library
>> is calypso, unfortunalty I haven't been able to use it, either from OSX or
>> ubuntu: it's blocked by https://github.com/Syniurge/Calypso/issues/41,
>> hoping someone can help here!
>>
>>
>>
>> On Wed, Aug 23, 2017 at 3:57 PM, lobo via Digitalmars-d
>>  wrote:
>>>
>>> [...]
>
>
> Thanks, I'll revisit Nim. As a team we're testing new languages as a larger
> plan to switch from C++. Nim we struck off 6 months ago because we found it
> not quite production ready.
>
> bye,
> lobo

Would love to hear more about your reasoning as I'm also occasionally
re-visiting it, do you have any writeup?


[Issue 17777] New: broken link: Download D 2.076.0 => 403 Forbidden

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

  Issue ID: 1
   Summary: broken link: Download D 2.076.0 => 403 Forbidden
   Product: D
   Version: D2
  Hardware: x86
OS: Mac OS X
Status: NEW
  Severity: normal
  Priority: P1
 Component: dlang.org
  Assignee: nob...@puremagic.com
  Reporter: timothee.co...@gmail.com

clicking on Download D 2.076.0
(http://downloads.dlang.org/releases/2.x/2.076.0)
released Aug 16, 2017

gives:

403 Forbidden

--


Re: HTOD

2017-08-23 Thread lobo via Digitalmars-d

On Thursday, 24 August 2017 at 01:51:25 UTC, Timothee Cour wrote:

[...]


nim:
it supports both targetting C++ (as well as C or javascript) 
and also
calling C++ via foreign function interface, eg here are some 
links:

https://github.com/nim-lang/Nim/wiki/Playing-with-CPP--VTABLE-from-Nim
https://stackoverflow.com/questions/29526958/wrapping-nested-templated-types-in-nim
https://forum.nim-lang.org/t/1056

for D, there's a project to support full C++ natively using 
clang library is calypso, unfortunalty I haven't been able to 
use it, either from OSX or ubuntu: it's blocked by 
https://github.com/Syniurge/Calypso/issues/41, hoping someone 
can help here!




On Wed, Aug 23, 2017 at 3:57 PM, lobo via Digitalmars-d 
 wrote:

[...]


Thanks, I'll revisit Nim. As a team we're testing new languages 
as a larger plan to switch from C++. Nim we struck off 6 months 
ago because we found it not quite production ready.


bye,
lobo


wrapping a C style delegate

2017-08-23 Thread Nicholas Wilson via Digitalmars-d-learn

I want to wrap:

ErrorEnum function(Struct* s, void function(Struct*, ErrorEnum 
status, void *userData) callback, void *userData, uint flags);


as a member of a wrapping struct

struct Mystruct
{
   Struct* s; // wrapped

 ErrorEnum addCallback(void delegate(Struct*, ErrorEnum 
status))

 {
 //...
 }
}


How do I wrap that?



Re: D as a Better C

2017-08-23 Thread Swoorup Joshi via Digitalmars-d-announce
On Wednesday, 23 August 2017 at 17:44:31 UTC, Jonathan M Davis 
wrote:
On Wednesday, August 23, 2017 13:12:04 Mike Parker via 
Digitalmars-d- announce wrote:

[...]


I confess that I tend to think of betterC as a waste of time. 
Clearly, there are folks who find it useful, but it loses so 
much that I see no point in using it for anything unless I have 
no choice. As long as attempts to improve it don't negatively 
impact normal D, then I don't really care what happens with it, 
but it's clearly not for me.


And it _is_ possible to use full-featured D from C/C++ when D 
does not control main. It's just more of a pain.


- Jonathan M Davis


Totally agree with this.


Re: Future of export

2017-08-23 Thread Nicholas Wilson via Digitalmars-d

On Thursday, 24 August 2017 at 00:31:26 UTC, solidstate1991 wrote:
There's already a DIP on the subject 
(https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP45.md), but it's pretty much abandoned. I however would like to see it becoming a subject of discussion. DIP45 should be done as soon as possible, so the D will be able to have a much better DLL support, which in turn will help both our development, both the adoption of the language.


Thanks. The interesting bit of that DIP w.r.t DIP1012 is


A single meaning of export

The classical solution to handle dllexport/dllimport attributes 
on Windows is to define macro that depending on the current 
build setting expands to __declspec(dllexport) or to 
__declspec(dllimport). This complicates the build setup and 
means that object files for a static library can't be mixed 
well with object files for a DLL. Instead we propose that 
exported data definitions are accompanied with an _imp_ pointer 
and always accessed through them. See the implementation detail 
section for how this will work for data symbols and function 
symbols. That way a compiled object file can be used for a DLL 
or a static library. And vice versa an object file can be 
linked against an import library or a static library.


I can't comment on the build system complexity that DIP1012 would 
add but It would allow us to do the C/C++ solution of export 
management.


I'll have a proper look over DIP45's review thread and put a 
summary here and see if we can get some discussion on it.


Re: HTOD

2017-08-23 Thread Timothee Cour via Digitalmars-d
> Do you know another language or tool that can call C++ natively?

nim:
it supports both targetting C++ (as well as C or javascript) and also
calling C++ via foreign function interface, eg here are some links:
https://github.com/nim-lang/Nim/wiki/Playing-with-CPP--VTABLE-from-Nim
https://stackoverflow.com/questions/29526958/wrapping-nested-templated-types-in-nim
https://forum.nim-lang.org/t/1056

for D, there's a project to support full C++ natively using clang
library is calypso, unfortunalty I haven't been able to use it, either
from OSX or ubuntu: it's blocked by
https://github.com/Syniurge/Calypso/issues/41, hoping someone can help
here!



On Wed, Aug 23, 2017 at 3:57 PM, lobo via Digitalmars-d
 wrote:
> On Wednesday, 23 August 2017 at 13:25:20 UTC, 12345swordy wrote:
>>
>> On Tuesday, 22 August 2017 at 19:55:53 UTC, Jacob Carlborg wrote:
>>>
>>> On 2017-08-22 19:47, 12345swordy wrote:
>>>
 Use Clang frontend?
>>>
>>>
>>> DStep [1] is doing that. It handles both GCC and Microsoft extensions.
>>>
>>> [1] https://github.com/jacob-carlborg/dstep
>>
>>
>> "Doesn't translate C++ at all"
>>
>> That's very disappointing. IMO, it should at least aim for the c++ 11
>> feature via using clang.
>
>
> Do you know another language or tool that can call C++ natively? I'm looking
> for native C++ interop either built in or via tooling.
>
> bye,
> lobo
>
>


Re: @safe(bool)

2017-08-23 Thread bitwise via Digitalmars-d

On Wednesday, 23 August 2017 at 13:28:37 UTC, 12345swordy wrote:

On Wednesday, 23 August 2017 at 02:24:51 UTC, bitwise wrote:

[...]

Platitudes cause poor language design, not the completely 
reasonable expectation of good tools.


And who is "Platitude" here specifically?


http://lmgtfy.com/?q=platitude ;)


Re: D as a Better C

2017-08-23 Thread 9il via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it. A fun read. And I'm 
personally happy to see the love this feature is getting. I 
have a project I'd like to use it with if I can ever make the 
time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


Thanks for this feature! Looking forward to see its future  --Ilya


Re: D as a Better C

2017-08-23 Thread H. S. Teoh via Digitalmars-d-announce
On Thu, Aug 24, 2017 at 12:35:22AM +, Michael V. Franklin via 
Digitalmars-d-announce wrote:
[...]
> Consider this:  Rust doesn't need a special switch to make it
> interoperable with C.  What's wrong with D's implementation that
> requires such things?  Granted, D is not Rust, but D's implementation
> could be improved to make it more competitive with Rust in these use
> cases.  For example, there is really no need for TypeInfo if you're
> not doing any dynanmic casts, but the current implementation generates
> it regardless.  I find -betterC to be somewhat of a copout for
> avoiding the hard work of improving D's implementation.
[...]

One thing that would help is if things like TypeInfo, ModuleInfo, etc.,
are only emitted on-demand, or if they are stored as weak symbols in the
object file so that the linker can just omit them if they are never
referenced.

Ideally, the GC would also be on-demand, but it's currently too tightly
integrated with druntime for this to be possible. At least, it would
take a huge amount of effort to make it work.  Similarly, thread-related
stuff might be difficult to make optional, since the D startup code is
dependent on it.

Other smaller things in druntime like string switches, array comparison
functions, etc., could possibly also be optionally included, but then
you'll need to link (parts of) druntime. It will be more troublesome,
but within the realm of possibility, I think.

I, for one, would be happier if D's features are more pay-as-you-go so
that simpler programs don't have to pull in a whole bunch of executable
bloat that's not actually going to be used.


T

-- 
Let's eat some disquits while we format the biskettes.


Re: D as a Better C

2017-08-23 Thread Michael V. Franklin via Digitalmars-d-announce
On Wednesday, 23 August 2017 at 17:44:31 UTC, Jonathan M Davis 
wrote:


I confess that I tend to think of betterC as a waste of time. 
Clearly, there are folks who find it useful, but it loses so 
much that I see no point in using it for anything unless I have 
no choice. As long as attempts to improve it don't negatively 
impact normal D, then I don't really care what happens with it, 
but it's clearly not for me.


And it _is_ possible to use full-featured D from C/C++ when D 
does not control main. It's just more of a pain.


I'm somewhat in agreement here.  I wouldn't call it a "waste of 
time", but I would prefer refactoring D's implementation to make 
using full-featured D from C/C++ less of a pain.  I fear, 
however, that -betterC will be the favored excuse for not 
pursuing or prioritizing such improvements.


Consider this:  Rust doesn't need a special switch to make it 
interoperable with C.  What's wrong with D's implementation that 
requires such things?  Granted, D is not Rust, but D's 
implementation could be improved to make it more competitive with 
Rust in these use cases.  For example, there is really no need 
for TypeInfo if you're not doing any dynanmic casts, but the 
current implementation generates it regardless.  I find -betterC 
to be somewhat of a copout for avoiding the hard work of 
improving D's implementation.


Mike


Re: Future of export

2017-08-23 Thread solidstate1991 via Digitalmars-d
On Wednesday, 23 August 2017 at 03:19:55 UTC, Nicholas Wilson 
wrote:

I have as part of DIP 1012

```
enum SymbolExport
{
neither,
dynamicImport,
dynamicExport
}

alias dynamicImport = SymbolExport .dynamicImport;
alias dynamicExport = SymbolExport .dynamicExport;
```

to replace the `export` storage visibility, So that one can do

```
version(MyLib_Build)
enum MyLibExport = dynamicExport;
else
enum MyLibExport = dynamicImport;

// Exported when building the shared object,
//imported when linking against the shared object.
@MyLibExport void foo(int x) { ... }
```

However Martin said in 
https://github.com/dlang/DIPs/pull/89/files#diff-26bf588c0174e6cd0fe3d4af615bebdaR120 that "That's not what is planned for export"


Last I heard (from Benjamins Thaut's DConf 2016 talk) was that 
nobody was using export because there was no corresponding 
import and no way to switch between them. Benjamin suggested 
that making it an attribute would fix that, hence it is part of 
DIP 1012.


What is planned for export?


There's already a DIP on the subject 
(https://github.com/dlang/DIPs/blob/master/DIPs/archive/DIP45.md), but it's pretty much abandoned. I however would like to see it becoming a subject of discussion. DIP45 should be done as soon as possible, so the D will be able to have a much better DLL support, which in turn will help both our development, both the adoption of the language.


Re: D Code to html

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

On Wednesday, 23 August 2017 at 20:03:16 UTC, Andre Pany wrote:

Hi,

how does the D syntax highlighting in e.g. 
https://dlang.org/blog/2017/08/23/d-as-a-better-c/ works?


From reading the html source code I understand there is some 
functionality prettyprint but not how it is included and what I 
have to do to use it in my page.


Kind regards
André


It's a Wordpress plugin:

https://products.askupasoftware.com/mivhak/


Re: Community Rant

2017-08-23 Thread Brad Roberts via Digitalmars-d



On 8/23/2017 3:58 PM, Mark via Digitalmars-d wrote:

On Tuesday, 22 August 2017 at 15:14:33 UTC, Jonathan Shamir wrote:

[...]

But lets be honest. If I was just interested to learn about this 
"modern system programming language" that is C++ done right, I would 
dismiss D very quickly. We need to get together as a community and 
rethink your priorities, because with problems like this we're making 
it very hard for newcomers to trust in this very poorly adapted language.


Programming tools used by day to day programmers should be a priority. 
Because everyone expects valgrind to work.


[...]


This kind of criticism comes up fairly often in the forums, maybe once 
every few weeks. I can link to the recent threads on the matter, but I'm 
sure you can make an educated guess about the responses therein. The 
gist of it, in my view, is that:


"[Making] D more approachable and attractive to people thinking of 
picking up the language."


just isn't a high priority right now.


That's one way to look at it.

Another, slightly more accurate and nuanced version is that there are 
many areas for improvement, and those that are doing work to improve 
things are doing them in areas they believe are important and useful for 
their work.  That there's not more in the area , that you (and 
others) believe is important, merely shows that the number that believe 
 is important enough to work on right now is close to zero.  That 
doesn't mean that  isn't also important, just that it's not at the 
top of the priority list for those getting things done.


Convince someone that  is higher priority than the things they're 
working on then you might see some movement on those fronts.  Or 
convince yourself that it's important enough to engage in yourself. 
This isn't really a community level issue so much as a very personal 
level issue.  It's not sufficient for something to be declared a 
community level priority if no one at the personal level is interested 
enough to contribute their time.


Re: HTOD

2017-08-23 Thread lobo via Digitalmars-d

On Wednesday, 23 August 2017 at 13:25:20 UTC, 12345swordy wrote:
On Tuesday, 22 August 2017 at 19:55:53 UTC, Jacob Carlborg 
wrote:

On 2017-08-22 19:47, 12345swordy wrote:


Use Clang frontend?


DStep [1] is doing that. It handles both GCC and Microsoft 
extensions.


[1] https://github.com/jacob-carlborg/dstep


"Doesn't translate C++ at all"

That's very disappointing. IMO, it should at least aim for the 
c++ 11 feature via using clang.


Do you know another language or tool that can call C++ natively? 
I'm looking for native C++ interop either built in or via tooling.


bye,
lobo




Re: Community Rant

2017-08-23 Thread Mark via Digitalmars-d

On Tuesday, 22 August 2017 at 15:14:33 UTC, Jonathan Shamir wrote:

[...]

But lets be honest. If I was just interested to learn about 
this "modern system programming language" that is C++ done 
right, I would dismiss D very quickly. We need to get together 
as a community and rethink your priorities, because with 
problems like this we're making it very hard for newcomers to 
trust in this very poorly adapted language.


Programming tools used by day to day programmers should be a 
priority. Because everyone expects valgrind to work.


[...]


This kind of criticism comes up fairly often in the forums, maybe 
once every few weeks. I can link to the recent threads on the 
matter, but I'm sure you can make an educated guess about the 
responses therein. The gist of it, in my view, is that:


"[Making] D more approachable and attractive to people thinking 
of picking up the language."


just isn't a high priority right now.


Re: gdc and ldc in MacPorts

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

On Wednesday, 23 August 2017 at 18:03:22 UTC, lanphuonglien wrote:
Whilst DMD seems to be in MacPorts, GDC and LDC appear not to 
be. Is this right? If it is then it is wrong – it would be 
great if the person handling the DMD port could be supported to 
get a LDC and GDC ports in place.


I am a user of MacOS maybe once per year, but I'll help as I 
can.


If you aren't set on MacPorts, you can use homebrew for ldc.
With regards to gdc: A word of caution: Supporting it as a 
separate package is a bit of a hassle, since it technically lives 
as part of the main gcc codebase (and you actually compile gcc 
with the D frontend enabled).


Re: D as a Better C

2017-08-23 Thread sarn via Digitalmars-d-announce
On Wednesday, 23 August 2017 at 17:44:31 UTC, Jonathan M Davis 
wrote:

I confess that I tend to think of betterC as a waste of time.


The overwhelming majority of programmers don't need betterC.  At 
all.  But today we live in a world where practically everything 
just builds on top of C, and we keep seeing how that goes wrong.  
I think Rust and betterC D are the best candidates we've got for 
replacing C everywhere C is used.


Re: D as a Better C

2017-08-23 Thread sarn via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 16:17:57 UTC, SrMordred wrote:

No structs in -betterC ???


I haven't tried the latest iteration of betterC yet, but the 
longstanding problem is that the compiler generates TypeInfo 
instances for structs, and TypeInfos are classes, which inherit 
from Object, which are implemented in the D runtime.  If you're 
using the current release of D, the workarounds are to include an 
implementation of Object so that classes work, or hack out the 
TypeInfo at link time.


Re: D as a Better C

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-announce
On Wednesday, 23 August 2017 at 17:43:27 UTC, Steven 
Schveighoffer wrote:

On 8/23/17 11:59 AM, Walter Bright wrote:

On 8/23/2017 7:37 AM, Steven Schveighoffer wrote:

How do dynamic closures work without the GC?


They don't allocate the closure on the GC heap. (Or do I have 
static/dynamic closures backwards?)


I thought "closure" means allocating the stack onto the heap so 
you can return the delegate with its context intact.


From 
https://en.wikipedia.org/wiki/Closure_(computer_programming) :


"A language implementation cannot easily support full closures 
if its run-time memory model allocates all automatic variables 
on a linear stack. In such languages, a function's automatic 
local variables are deallocated when the function returns. 
However, a closure requires that the free variables it 
references survive the enclosing function's execution. 
Therefore, those variables must be allocated so that they 
persist until no longer needed, typically via heap allocation, 
rather than on the stack, and their lifetime must be managed so 
they survive until all closures referencing them have are no 
longer in use."


Right, so if we wanted to support closures in betterC (we don't 
now, as my earlier example shows), they'd need a separate 
lifetime management implementation.
The two straightforward ones are either disable copying of 
closures in betterC (only moving them), so a single ownership 
model of their heap allocated context pointer is possible 
(deallocating the memory once the closure is destroyed), or make 
them reference counted.
The first has the disadvantage that you can't have two closures 
point to the same heap context (though to be honest, I haven't 
seen a codebase so far that actually uses that), but it should be 
trivial to implement. The RC variant is more complex (it would 
require an analysis if reference cycles can occur), but I think 
this might be one of the cases where RC is the right solution 
(and we might even consider using RC in normal D as well, if it 
works sanely).


(SIMD) Optimized multi-byte chunk scanning

2017-08-23 Thread Nordlöw via Digitalmars-d-learn
I recall seeing some C/C++/D code that optimizes the comment- and 
whitespace-skipping parts (tokens) of lexers by operating on 2, 4 
or 8-byte chunks instead of single-byte chunks. This in the case 
when token-terminators are expressed as sets of (alternative) 
ASCII-characters.


For instance, when searching for the end of a line comment, I 
would like to speed up the while-loop in


size_t offset;
string input = "// \n"; // a line-comment string
import std.algorithm : among;
// until end-of-line or file terminator
while (!input[offset].among!('\0', '\n', '\r')
{
++offset;
}

by taking `offset`-steps larger than one.

Note that my file reading function that creates the real `input`, 
appends a '\0' at the end to enable sentinel-based search as 
shown in the call to `among` above.


I further recall that there are x86_64 intrinsics that can be 
used here for further speedups.


Refs, anyone?


Re: Quora

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

A few other ones :

https://www.quora.com/Is-C++-the-best-programming-language-to-learn-first
https://www.quora.com/What-are-some-programming-languages-that-I-should-learn
https://www.quora.com/How-do-I-learn-coding-7
https://www.quora.com/What-should-I-start-with-in-order-to-learn-computer-programming-well-Which-languages-and-any-other-basic-skills-What-are-some-experiences-which-people-have-had

By the way, I think that the D tutorial on TutorialsPoint should 
be promoted A LOT more on the Dlang.org website.


And even if I agree like everybody that Ali's book is probably 
the best one around, a website is free and directly accessible to 
anybody interested in learning programming with D...





Re: Tools to help me find memory leaks?

2017-08-23 Thread Stefan Koch via Digitalmars-d-learn

On Wednesday, 23 August 2017 at 17:30:40 UTC, Drake44 wrote:
I'm on a Windows 7 machine and I'm using VisualD as my IDE. I'm 
trying to work out what's chewing up all the RAM in a program 
I'm writing... is there a tool that I can use that'll show me 
what in my program keeps allocating memory?


Thanks


If you are using the gc then compile with -profile=gc.
Which will generate a file that logs all gc allocations.
On exiting the program normally.
So make sure you can exit via a keypress or after a timelimit has 
passed.


If you are using malloc / calloc / free
you'll have to use a tool like valgrind.


Re: Visual Studio Code code-d serve-d beta release

2017-08-23 Thread WebFreak001 via Digitalmars-d-announce
On Wednesday, 23 August 2017 at 15:41:02 UTC, Paolo Invernizzi 
wrote:

On Saturday, 5 August 2017 at 22:43:31 UTC, WebFreak001 wrote:

[...]


It seems that under macOS, the linux executable is used, with a 
fresh install...


iMac:~ pinver$ uname -a
Darwin iMac.local 17.0.0 Darwin Kernel Version 17.0.0: Wed Aug 
16 20:06:51 PDT 2017; root:xnu-4570.1.45~23/RELEASE_X86_64 
x86_64
iMac:~ pinver$ file 
/Users/pinver/.vscode/extensions/webfreak.code-d-beta-0.17.3/bin/serve-d/serve-d

/Users/pinver/.vscode/extensions/webfreak.code-d-beta-0.17.3/bin/serve-d/serve-d:
 ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, 
interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, 
BuildID[sha1]=788ec4845beac53f20ad0c0279f6b143bf9e42cc, with debug_info, not 
stripped

Version 0.17.3 ...

---
Paolo


uh serve-d doesn't have any prebuilt binaries yet so that is 
compiled on your PC and should be correct


D Code to html

2017-08-23 Thread Andre Pany via Digitalmars-d-learn

Hi,

how does the D syntax highlighting in e.g. 
https://dlang.org/blog/2017/08/23/d-as-a-better-c/ works?


From reading the html source code I understand there is some 
functionality prettyprint but not how it is included and what I 
have to do to use it in my page.


Kind regards
André


Re: HTOD

2017-08-23 Thread 12345swordy via Digitalmars-d

On Wednesday, 23 August 2017 at 14:12:55 UTC, jmh530 wrote:

On Wednesday, 23 August 2017 at 13:25:20 UTC, 12345swordy wrote:


"Doesn't translate C++ at all"

That's very disappointing. IMO, it should at least aim for the 
c++ 11 feature via using clang.


Very disappointing?


Yes I find it disappointing. Does my disappointment bother you?


Re: D as a Better C

2017-08-23 Thread jmh530 via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 17:39:00 UTC, Walter Bright wrote:

On 8/23/2017 10:26 AM, jmh530 wrote:
Am I correct that betterC requires main to be extern(C) and 
must act like a C main (i.e. no void return)?


Yes.


This might be added to
http://dlang.org/dmd-windows.html#switch-betterC
or
http://dlang.org/spec/betterc.html




Is that something that can be changed in the future?


Yes, but I don't see a need for it.


Fair enough. A version statement could handle it

version(BetterC)
{
extern(C) int main()
{
callRealMain();
}
}
else
{
void main()
{
callRealMain();
}
}



Re: Community Rant

2017-08-23 Thread Ali Çehreli via Digitalmars-d

On 08/22/2017 08:24 AM, ixid wrote:

On Tuesday, 22 August 2017 at 15:14:33 UTC, Jonathan Shamir wrote:

various.


Out of interest did you pick up D before or after joining the start up?
If before did you introduce D to them or were they already using it?


Weka uses D after their CTO Liran's evaluation of a number of 
programming languages. Liran explains why he chose D and why he still 
thinks D was the right choice in his a couple of DConf talks.


I worked at Weka for a while where I met many wonderful people like 
Jonathan. Although they were being "forced" to use D, nobody was 
seriously complaining. :)


Now I work with an ex-Weka employee as an ex-Weka employee myself. That 
other person insisted that he should use D in his piece of the product. 
Sanity exists... ;)


Ali



gdc and ldc in MacPorts

2017-08-23 Thread lanphuonglien via Digitalmars-d
Whilst DMD seems to be in MacPorts, GDC and LDC appear not to be. 
Is this right? If it is then it is wrong – it would be great if 
the person handling the DMD port could be supported to get a LDC 
and GDC ports in place.


I am a user of MacOS maybe once per year, but I'll help as I can.


Re: D as a Better C

2017-08-23 Thread Steven Schveighoffer via Digitalmars-d-announce

On 8/23/17 11:59 AM, Walter Bright wrote:

On 8/23/2017 7:37 AM, Steven Schveighoffer wrote:

How do dynamic closures work without the GC?


They don't allocate the closure on the GC heap. (Or do I have 
static/dynamic closures backwards?)


I thought "closure" means allocating the stack onto the heap so you can 
return the delegate with its context intact.


From https://en.wikipedia.org/wiki/Closure_(computer_programming) :

"A language implementation cannot easily support full closures if its 
run-time memory model allocates all automatic variables on a linear 
stack. In such languages, a function's automatic local variables are 
deallocated when the function returns. However, a closure requires that 
the free variables it references survive the enclosing function's 
execution. Therefore, those variables must be allocated so that they 
persist until no longer needed, typically via heap allocation, rather 
than on the stack, and their lifetime must be managed so they survive 
until all closures referencing them have are no longer in use."


-Steve


Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 10:17 AM, Kagamin wrote:

Also how assert failure works in C?


It calls the C assert failure function.



Re: D as a Better C

2017-08-23 Thread Jonathan M Davis via Digitalmars-d-announce
On Wednesday, August 23, 2017 13:12:04 Mike Parker via Digitalmars-d-
announce wrote:
> To coincide with the improvements to -betterC in the upcoming DMD
> 2.076, Walter has published a new article on the D blog about
> what it is and why to use it. A fun read. And I'm personally
> happy to see the love this feature is getting. I have a project
> I'd like to use it with if I can ever make the time for it!
>
> The blog:
>
> https://dlang.org/blog/2017/08/23/d-as-a-better-c/
>
> Reddit:
> https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/

I confess that I tend to think of betterC as a waste of time. Clearly, there
are folks who find it useful, but it loses so much that I see no point in
using it for anything unless I have no choice. As long as attempts to
improve it don't negatively impact normal D, then I don't really care what
happens with it, but it's clearly not for me.

And it _is_ possible to use full-featured D from C/C++ when D does not
control main. It's just more of a pain.

- Jonathan M Davis



Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 10:26 AM, jmh530 wrote:
Am I correct that betterC requires main to be extern(C) and must act like a C 
main (i.e. no void return)?


Yes.


Is that something that can be changed in the future?


Yes, but I don't see a need for it.


Re: D as a Better C

2017-08-23 Thread Steven Schveighoffer via Digitalmars-d-announce

On 8/23/17 11:52 AM, Walter Bright wrote:

On 8/23/2017 7:24 AM, Steven Schveighoffer wrote:
Looks like there are some outstanding requests to be fulfilled before 
it's pulled.


I don't agree that the requests improve matters.


You may want to mention that in the PR. Right now it just looks like you 
haven't seen or responded to the requests.


-Steve


Re: D as a Better C

2017-08-23 Thread Steven Schveighoffer via Digitalmars-d-announce

On 8/23/17 11:56 AM, Walter Bright wrote:

On 8/23/2017 7:10 AM, Steven Schveighoffer wrote:

Nope.


A ModuleInfo is generated, as well as FMB/FM/FME sections. Those 
sections may not work with the C runtime.


My point was simply that your small example doesn't cause any runtime or 
link time errors. You need something more complicated to require betterC.


Not sure if ModuleInfo is generated. IIRC, Martin made it so it's not if 
no usage of the ModuleInfo is apparent.


Yes, adding a struct causes link errors, but not because of ModuleInfo, 
it's because of the expected TypeInfo.


-Steve


Tools to help me find memory leaks?

2017-08-23 Thread Drake44 via Digitalmars-d-learn
I'm on a Windows 7 machine and I'm using VisualD as my IDE. I'm 
trying to work out what's chewing up all the RAM in a program I'm 
writing... is there a tool that I can use that'll show me what in 
my program keeps allocating memory?


Thanks


Re: D as a Better C

2017-08-23 Thread jmh530 via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 14:01:30 UTC, jmh530 wrote:


Great piece.

It might be useful to beef up the documentation on some of the 
things that betterC changes. For instance, here

http://dlang.org/dmd-windows.html#switch-betterC
links to TypeInfo, which has like one line of explanation of 
what it's for, and ModuleInfo isn't linked to at all (and I'm 
still a little unclear on what that does).



Am I correct that betterC requires main to be extern(C) and must 
act like a C main (i.e. no void return)?


Is that something that can be changed in the future? For 
instance, the simplest change would be if the compiler knows that 
its betterC, then it can insert extern(C) to main. A second 
adjustment could potentially to re-write D's void main's to int 
and add in a return. The first seems like a good idea 
superficially, but I'm not 100% on the second.


Re: D as a Better C

2017-08-23 Thread Kagamin via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 14:00:34 UTC, Walter Bright wrote:
One of the reasons people use C is to get that small footprint. 
This has been a large barrier to C programs making use of D.


Not a better C, but intermediate D has small footprint for me too.
7.5kb totext.exe (encodes stdin to base64 and writes to stdout) - 
wrote it to put images in xml for opensearch descriptions.

12.5kb retab.exe (retabifies source code with various features)
5.5kb keepower.exe (manages screen saver and power settings 
because of obnoxious domain policy)

14.5kb fsum.exe (computes various hash sums of a file)

Additional features: string switch, array cast. Also how assert 
failure works in C? Mine shows a nice formatted message.


[Issue 17775] dmd master __VERSION__ should match the major release that it will be for

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

--- Comment #4 from Jonathan M Davis  ---
(In reply to ZombineDev from comment #3)
> I agree that it's quite annoying. Perhaps we can add another predefined
> constant like __IS_DEV_VERSION__ which would evaluate to true iff the
> ddmd.globals.global._version has any non-digit character after the minor
> version (or simply if its length is > 8)?

The problem with that is that then you're testing specifically for dmd master
not that the code is newer than a particular release. If a change is made in
dmd master that's going to go in the next release, and __VERSION__ in dmd
master is the version of the next release, then you can check __VERSION__, and
the code will continue to do the right thing once dmd master becomes the next
release, but if you're checking __IS_DEV_VERSION__, then that doesn't work.
You'd have to change your code to use __VERSION__ once the next release is out.

While I can understand that with however the version numbers are currently
being generated, there may be issues having __VERSION__ be the number of the
next release in master rather than the current reelase, I really think that if
you consider what __VERSION__ is for, it really doesn't make sense for it to
give the same number as the most recent release for master. That destroys its
ability to be used for what it's designed for when dmd master is involved.

--


[Issue 17775] dmd master __VERSION__ should match the major release that it will be for

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

--- Comment #3 from ZombineDev  ---
I agree that it's quite annoying. Perhaps we can add another predefined
constant like __IS_DEV_VERSION__ which would evaluate to true iff the
ddmd.globals.global._version has any non-digit character after the minor
version (or simply if its length is > 8)?

--


Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 6:12 AM, Mike Parker wrote:

The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


Now on the front page of news.ycombinator.com !


Re: D as a Better C

2017-08-23 Thread XavierAP via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it.


I like this concept of "upward compatibility," -- although 
opposed to backward it should be phrased "forward."


Will share also this one on LinkedIn...
I see D has official account on Facebook, Twitter, Reddit... No 
interest in LinkedIn? I think it can also be a good promotion 
platform for D.


Re: D as a Better C

2017-08-23 Thread via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 16:17:57 UTC, SrMordred wrote:
On Wednesday, 23 August 2017 at 15:53:11 UTC, Walter Bright 
wrote:

On 8/23/2017 7:10 AM, Steven Schveighoffer wrote:
It's only if you do something that needs the runtime, such as 
static ctors, or use the GC.


Or use asserts, or even declare a struct.


No structs in -betterC ???


IIUC, Steven's question was about the need for the `-betterC` 
switch - in his small example there was no need for it. Walter 
pointed out that without -betterC using structs cause link-time 
references to druntime, which are avoided by the use of the 
`-betterC` switch.
Though, one particular thing that doesn't work in `-betterC` 
w.r.t. structs is RAII. You can still call manually the 
destructor, but that's a crude hack. Work on RAII for `-betterC` 
is work in progress.


Re: D as a Better C

2017-08-23 Thread SrMordred via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 15:53:11 UTC, Walter Bright wrote:

On 8/23/2017 7:10 AM, Steven Schveighoffer wrote:
It's only if you do something that needs the runtime, such as 
static ctors, or use the GC.


Or use asserts, or even declare a struct.


No structs in -betterC ???


Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 7:37 AM, Steven Schveighoffer wrote:

How do dynamic closures work without the GC?


They don't allocate the closure on the GC heap. (Or do I have static/dynamic 
closures backwards?)


Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 8:05 AM, John Colvin wrote:

"D polymorphic classes will not, as they rely on the garbage collector."

They do? Don't have to allocate classes on the GC heap.


Using them without the GC is a fairly advanced technique, and I don't want to 
deal with people writing:


C c = new C();

and complaining that it doesn't work.


Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 7:10 AM, Steven Schveighoffer wrote:

Nope.


A ModuleInfo is generated, as well as FMB/FM/FME sections. Those sections may 
not work with the C runtime.


Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 7:10 AM, Steven Schveighoffer wrote:
It's only if you do something that needs the runtime, such as static ctors, or 
use the GC.


Or use asserts, or even declare a struct.



Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 7:24 AM, Steven Schveighoffer wrote:

Looks like there are some outstanding requests to be fulfilled before it's 
pulled.


I don't agree that the requests improve matters.



Re: Visual Studio Code code-d serve-d beta release

2017-08-23 Thread Paolo Invernizzi via Digitalmars-d-announce

On Saturday, 5 August 2017 at 22:43:31 UTC, WebFreak001 wrote:
You might remember the blog post from a while back about 
workspace-d and serve-d, I just released a beta version on the 
visual studio marketplace that allows you to try out the latest 
features of serve-d. Note that this version might easily break 
in the future, but for the next few days I am trying to gain 
some feedback. If you are a user of code-d and if you want to 
try out the new version please uninstall code-d and install 
code-d-beta 
(https://marketplace.visualstudio.com/items?itemName=webfreak.code-d-beta, it's version 0.16.1) and just try to use it.


[...]


It seems that under macOS, the linux executable is used, with a 
fresh install...


iMac:~ pinver$ uname -a
Darwin iMac.local 17.0.0 Darwin Kernel Version 17.0.0: Wed Aug 16 
20:06:51 PDT 2017; root:xnu-4570.1.45~23/RELEASE_X86_64 x86_64
iMac:~ pinver$ file 
/Users/pinver/.vscode/extensions/webfreak.code-d-beta-0.17.3/bin/serve-d/serve-d

/Users/pinver/.vscode/extensions/webfreak.code-d-beta-0.17.3/bin/serve-d/serve-d:
 ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, 
interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, 
BuildID[sha1]=788ec4845beac53f20ad0c0279f6b143bf9e42cc, with debug_info, not 
stripped

Version 0.17.3 ...

---
Paolo


Re: D as a Better C

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-announce
On Wednesday, 23 August 2017 at 15:17:31 UTC, Moritz Maxeiner 
wrote:
On Wednesday, 23 August 2017 at 14:37:19 UTC, Steven 
Schveighoffer wrote:

On 8/23/17 9:12 AM, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it. A fun read. And I'm 
personally happy to see the love this feature is getting. I 
have a project I'd like to use it with if I can ever make the 
time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


How do dynamic closures work without the GC?

Nice article, BTW.

-Steve


They don't (right now, using dmd ~master), because they depend 
on druntime:


[...]


Sorry, I screwed up when pasting. Here's what I meant to post:


--- a.c ---
#include 
#include 

uint32_t foo();

int main(int argc, char** argv)
{
uint32_t x = foo();
printf("%d\n", x);
return 0;
}
---

--- b.d ---
auto test()
{
uint i = 42;
return () {
return i;
};
}

$ dmd -c -betterC b.d
$ gcc a.c b.d
Undefined symbols for architecture x86_64:
  "__d_allocmemory", referenced from:
  _D1b4testFNaNbNfZDFNaNbNiNfZk in b.o


Re: D as a Better C

2017-08-23 Thread yawniek via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it. A fun read. And I'm 
personally happy to see the love this feature is getting. I 
have a project I'd like to use it with if I can ever make the 
time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


nice article, however very unfortunate  introduction for the ADHD 
Generation as you start reading and you get put of by historical 
disabilities of D that are not true anymore. you may want to edit 
that and add the "until now" beforehand ;)


Re: D as a Better C

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-announce
On Wednesday, 23 August 2017 at 14:37:19 UTC, Steven 
Schveighoffer wrote:

On 8/23/17 9:12 AM, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it. A fun read. And I'm 
personally happy to see the love this feature is getting. I 
have a project I'd like to use it with if I can ever make the 
time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


How do dynamic closures work without the GC?

Nice article, BTW.

-Steve


They don't (right now, using dmd ~master), because they depend on 
druntime:


--- a.c ---
#include 
#include 

uint32_t foo();

int main(int argc, char** argv)
{
uint32_t x = foo();
printf("%d\n", x);
}
---

--- b.d ---
auto test()
{
uint i = 42;
return () {
return i;
};
}

oo()
{
auto x = test();
return x();
}
---

$ dmd -c -betterC b.d
$ gcc a.c b.d
Undefined symbols for architecture x86_64:
  "__d_allocmemory", referenced from:
  _D1b4testFNaNbNfZDFNaNbNiNfZk in b.o
ld: symbol(s) not found for architecture x86_64extern(C) uint 
foo()

{
auto x = test();
return x();
}
---

$ dmd -c -betterC b.d
$ gcc a.c b.d
Undefined symbols for architecture x86_64:
  "__d_allocmemory", referenced from:
  _D1b4testFNaNbNfZDFNaNbNiNfZk in b.o



[Issue 17775] dmd master __VERSION__ should match the major release that it will be for

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

--- Comment #2 from Jonathan M Davis  ---
(In reply to ZombineDev from comment #1)
> This was changed in https://github.com/dlang/dmd/pull/6935.

Drat. Well, I can't say that I understand how all of that stuff with the
release process works and how dmd knows what its version is, but the fact that
__VERSION__ for master is not a higher number than the latest release is a
definite problem for any code that needs to do something differently with
master due to upcoming changes or whatnot. I ran into this problem recently
when making some changes to vibe.d.

--


Re: D as a Better C

2017-08-23 Thread John Colvin via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it. A fun read. And I'm 
personally happy to see the love this feature is getting. I 
have a project I'd like to use it with if I can ever make the 
time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


"D polymorphic classes will not, as they rely on the garbage 
collector."


They do? Don't have to allocate classes on the GC heap.


Re: dub zsh completion

2017-08-23 Thread Jonathan M Davis via Digitalmars-d-announce
On Tuesday, August 22, 2017 22:35:53 Johannes Loher via Digitalmars-d-
announce wrote:
> I created a zsh completion script for dub. It is not perfect, but
> it does many things well already. You can find it here:
> https://github.com/ghost91-/dub-zsh-completion.
>
> I have seen that bash and fish completion scripts are included in
> the dub github repo. If people are interested in this, I could
> create a pull request to also add the zsh completion script.
>
> I hope this helps some people :)

Wait, you mean that there are shells other than zsh? ;)

Thanks. I'll have to check this out.

- Jonathan M Davis



[Issue 17776] New: highlight error in betterC assert messages

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

  Issue ID: 17776
   Summary: highlight error in betterC assert messages
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Keywords: betterC
  Severity: normal
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: b2.t...@gmx.com

With DMD 2.076 beta or ~master run

---
#!dmd -betterC
extern(C) int main(char** args, int argc)
{
assert(0 == 42);
return 0;
}
---

To see:

> Assertion `a == 42' failed.

I suppose that the right most expression delimiter should also be a backtick.

--


Re: D as a Better C

2017-08-23 Thread Steven Schveighoffer via Digitalmars-d-announce

On 8/23/17 9:12 AM, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming DMD 2.076, 
Walter has published a new article on the D blog about what it is and 
why to use it. A fun read. And I'm personally happy to see the love this 
feature is getting. I have a project I'd like to use it with if I can 
ever make the time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


How do dynamic closures work without the GC?

Nice article, BTW.

-Steve


Re: D as a Better C

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 14:00:34 UTC, Walter Bright wrote:

On 8/23/2017 6:28 AM, Moritz Maxeiner wrote:


I've been mixing C and full D for a while now (on Linux) by 
either having the main C program call rt_init/rt_term directly 
(if druntime is linked in when building a mixed C/D 
application), or have Runtime.initialize/Runtime.terminate be 
called from D via some plugin_load/plugin_unload functionality 
when using D shared libraries.

Why is this not considered practical?


Because in order to add a D function as trivial as:

   int foo() { return 3; }

to a C program, now the C program has to link to druntime, and 
the program no longer has a small footprint. One of the reasons 
people use C is to get that small footprint. This has been a 
large barrier to C programs making use of D.


Thank you, are there other factors involved, or is it only 
impractical for people who require minimal application size / 
memory footprint, then?


Re: D as a Better C

2017-08-23 Thread Steven Schveighoffer via Digitalmars-d-announce

On 8/23/17 10:11 AM, Walter Bright wrote:

On 8/23/2017 7:01 AM, jmh530 wrote:
ModuleInfo isn't linked to at all (and I'm still a little unclear on 
what that does).


That's because ModuleInfo doesn't appear in the online documentation due 
to having a malformed Ddoc comment. I fixed it here:


   https://github.com/dlang/druntime/pull/1906

but nobody has pulled it.


Looks like there are some outstanding requests to be fulfilled before 
it's pulled.


-Steve


Re: Community Rant

2017-08-23 Thread Ecstatic Coder via Digitalmars-d
But lets be honest. If I was just interested to learn about 
this "modern system programming language" that is C++ done 
right, I would dismiss D very quickly. We need to get together 
as a community and rethink your priorities, because with 
problems like this we're making it very hard for newcomers to 
trust in this very poorly adapted language.


Programming tools used by day to day programmers should be a 
priority. Because everyone expects valgrind to work.


The standard library should be a priority. It's far from 
complete (hopefully my company will contribute in this respect 
in the near future).


The DUB package repository is horrible! More often than not, 
the packages are so poorly written I end up just writing my own 
implementation. Adding the ability to "rate" packages would go 
a long way in improving the situation.


I understand hacking the frontend is way more interesting to 
most of the community. But if we don't find the time to improve 
on our visibility and language maturity, D will never get the 
attention it deserves.


+1


Re: D as a Better C

2017-08-23 Thread Meta via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 14:01:30 UTC, jmh530 wrote:

On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it. A fun read. And I'm 
personally happy to see the love this feature is getting. I 
have a project I'd like to use it with if I can ever make the 
time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


Great piece.

It might be useful to beef up the documentation on some of the 
things that betterC changes. For instance, here

http://dlang.org/dmd-windows.html#switch-betterC
links to TypeInfo, which has like one line of explanation of 
what it's for, and ModuleInfo isn't linked to at all (and I'm 
still a little unclear on what that does).


Walter has made a PR to improve the ModuleInfo documentation: 
https://github.com/dlang/druntime/pull/1906


Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 7:01 AM, jmh530 wrote:
ModuleInfo isn't linked to at all (and I'm still a little unclear on what that 
does).


That's because ModuleInfo doesn't appear in the online documentation due to 
having a malformed Ddoc comment. I fixed it here:


  https://github.com/dlang/druntime/pull/1906

but nobody has pulled it.


Re: D as a Better C

2017-08-23 Thread Steven Schveighoffer via Digitalmars-d-announce

On 8/23/17 10:00 AM, Walter Bright wrote:

On 8/23/2017 6:28 AM, Moritz Maxeiner wrote:

Interesting article, though one thing that I'm confused by is

Hence D libraries remain inaccessible to C programs, and chimera 
programs (a mix of C and D) are not practical. One cannot 
pragmatically “try out” D by add D modules to an existing C program.


I've been mixing C and full D for a while now (on Linux) by either 
having the main C program call rt_init/rt_term directly (if druntime 
is linked in when building a mixed C/D application), or have 
Runtime.initialize/Runtime.terminate be called from D via some 
plugin_load/plugin_unload functionality when using D shared libraries.

Why is this not considered practical?


Because in order to add a D function as trivial as:

int foo() { return 3; }

to a C program, now the C program has to link to druntime, and the 
program no longer has a small footprint. One of the reasons people use C 
is to get that small footprint. This has been a large barrier to C 
programs making use of D.




Nope.

Stevens-MacBook-Pro:testd steves$ cat testdfunc.d
extern(C) int foo() { return 3; }
Stevens-MacBook-Pro:testd steves$ cat testdfunc_c.c
#include 
extern int foo();

int main()
{
printf("%d\n", foo());
}
Stevens-MacBook-Pro:testd steves$ dmd -c testdfunc.d
Stevens-MacBook-Pro:testd steves$ gcc -o testdfunc testdfunc_c.c testdfunc.o
Stevens-MacBook-Pro:testd steves$ ./testdfunc
3


It's only if you do something that needs the runtime, such as static 
ctors, or use the GC.


-Steve


Re: HTOD

2017-08-23 Thread jmh530 via Digitalmars-d

On Wednesday, 23 August 2017 at 13:25:20 UTC, 12345swordy wrote:


"Doesn't translate C++ at all"

That's very disappointing. IMO, it should at least aim for the 
c++ 11 feature via using clang.


Very disappointing? It's not trivial to call C++ from another 
language.


Re: D as a Better C

2017-08-23 Thread jmh530 via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it. A fun read. And I'm 
personally happy to see the love this feature is getting. I 
have a project I'd like to use it with if I can ever make the 
time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


Great piece.

It might be useful to beef up the documentation on some of the 
things that betterC changes. For instance, here

http://dlang.org/dmd-windows.html#switch-betterC
links to TypeInfo, which has like one line of explanation of what 
it's for, and ModuleInfo isn't linked to at all (and I'm still a 
little unclear on what that does).


Re: D as a Better C

2017-08-23 Thread Walter Bright via Digitalmars-d-announce

On 8/23/2017 6:28 AM, Moritz Maxeiner wrote:

Interesting article, though one thing that I'm confused by is

Hence D libraries remain inaccessible to C programs, and chimera programs (a 
mix of C and D) are not practical. One cannot pragmatically “try out” D by 
add D modules to an existing C program.


I've been mixing C and full D for a while now (on Linux) by either having the 
main C program call rt_init/rt_term directly (if druntime is linked in when 
building a mixed C/D application), or have Runtime.initialize/Runtime.terminate 
be called from D via some plugin_load/plugin_unload functionality when using D 
shared libraries.

Why is this not considered practical?


Because in order to add a D function as trivial as:

   int foo() { return 3; }

to a C program, now the C program has to link to druntime, and the program no 
longer has a small footprint. One of the reasons people use C is to get that 
small footprint. This has been a large barrier to C programs making use of D.




Re: DerelictGL3 reload crashes in 32 builds

2017-08-23 Thread Igor via Digitalmars-d-learn

On Wednesday, 23 August 2017 at 12:59:38 UTC, Mike Parker wrote:

On Tuesday, 22 August 2017 at 12:03:18 UTC, Igor wrote:


[...]


I'm not sure what you're referring to. There are a few static 
if(Derelict_OS_Android) blocks in there as well.


[...]


Ok Mike. Thanks for the info. If I learn anything new about the 
issue I will post it to the github.




Re: Long File path Exception:The system cannot find the path specified

2017-08-23 Thread Vino.B via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 13:14:31 UTC, Moritz Maxeiner 
wrote:

On Wednesday, 23 August 2017 at 13:04:28 UTC, Vino.B wrote:


The line it complains is 
std.file.FileException@std\file.d(3713):even after enabling 
debug it points to the same


Output:
D:\DScript>rdmd -debug Test.d -r  dryrun

std.file.FileException@std\file.d(3713): 
N:\PROD_TEAM\TST_BACKUP\abcyf0\TST_BATS\j2ee_backup\cluster\states0\apps\bat.com\tc~bat~agent~application~e2emai~std~collectors\servlet_jsp\tc~bat~agent~application~e2emai~std~collectors\root\WEB-INF\entities\DataCollectionPushFileContentScannerTypeBuilder: The system cannot find the path specified.


0x00431A56
0x00429801


You need to compile with debug info (option `-g`), not compile 
in debug code (option `-debug`).

What's the (full) stack trace when compiling with debug info?


Hi,

 Please find the output and the entire program below after 
executing with option -g.



Program:

import std.file: dirEntries, isFile, SpanMode, remove, 
rmdirRecurse, exists, mkdir;

import std.stdio: writeln, writefln, File;
import std.algorithm: filter;
import std.array: array;
import std.path: globMatch, baseName;
/**/
/* Global Valiables   */
/**/
int SizeDir = 10;

/**/
/* Folder Lists   */
/**/
auto SizeDirlst = [ "N:\\PROD_TEAM", "P:\\TEAM" ];
/**/
/* Function : Size of Non DND Dir List*/
/**/
void SizeDirList (string[] SzDNDlst)
{
 ulong subdirTotal = 0;
 foreach (string i; SzDNDlst[0 .. $])
 {
  auto dFiles = dirEntries(i, SpanMode.shallow).filter!(a => 
a.isDir && !globMatch(a.baseName, "*DND*")).array;

  foreach (d; dFiles)
{
auto SdFiles = dirEntries(d, 
SpanMode.breadth).array;
foreach (f; SdFiles)
{
subdirTotal += f.size;
}
   ulong subdirTotalGB = 
(subdirTotal/1024/1024/1024);
   if (subdirTotalGB > SizeDir)
{
writefln("%-63s %s", d, subdirTotalGB);
}
subdirTotal = 0;
}   
 }
}

//
/* Main   
 */

//
void main ()
{
 SizeDirList(SizeDirlst);
}


Output:

D:\\DScript>rdmd -g Test.d -r  dryrun
N:\PROD_TEAM\PREBACKUP   
97


N:\PROD_TEAM\TST_BACKUP\abcyf0\TST_BATS\j2ee_backup\cluster\states0\apps\bat.com\tc~bat~agent~application~e2emai~std~collectors\servlet_jsp\tc~bat~agent~application~e2emai~std~collectors\root\WEB-INF\entities\DataCollectionPushFileContentScannerTypeBuilder:
 The system cannot find the path specified.

0x00415742 in @safe bool std.file.cenforce!(bool).cenforce(bool, 
lazy const(char)[], immutable(char)[], uint)

0x0040EA79 in void std.file.DirIteratorImpl.popFront()
0x00404948 in void 
std.array.Appender!(std.file.DirEntry[]).Appender.put!(std.file.DirEntry).put(std.file.DirEntry) at C:\D\dmd2\windows\bin\..\

..\src\phobos\std\array.d(2919)
0x00404B94 in std.file.DirEntry[] 
std.array.array!(std.file.DirIterator).array(std.file.DirIterator) at C:\D\dmd2\windows\bin\..\..\src\phobos\s

td\array.d(137)
0x00402363 in void Size.SizeDirList(immutable(char)[][]) at 
D:\DScript\Test.d(26)

0x00402468 in _Dmain at D:\DScript\Test.d(46)
0x0040E323 in 
D2rt6dmain211_d_run_mainUiPPaPUAAaZiZ6runAllMFZ9__lambda1MFZv
0x0040E2E7 in void rt.dmain2._d_run_main(int, char**, extern (C) 
int function(char[][])*).runAll()

0x0040E1E8 in _d_run_main
0x0040DCB8 in main at D:\DScript\Test.d(7)
0x00459DA9 in mainCRTStartup
0x75CE336A in BaseThreadInitThunk
0x775F9902 in RtlInitializeExceptionChain
0x775F98D5 in RtlInitializeExceptionChain

Lines in the script.
D:\DScript\Test.d(26) : auto SdFiles = dirEntries(d, 
SpanMode.breadth).array;

D:\DScript\Test.d(46) : SizeDirList(SizeDirlst);
D:\DScript\Test.d(7) : /* Global Valiables
   */



Re: D as a Better C

2017-08-23 Thread Moritz Maxeiner via Digitalmars-d-announce

On Wednesday, 23 August 2017 at 13:12:04 UTC, Mike Parker wrote:
To coincide with the improvements to -betterC in the upcoming 
DMD 2.076, Walter has published a new article on the D blog 
about what it is and why to use it. A fun read. And I'm 
personally happy to see the love this feature is getting. I 
have a project I'd like to use it with if I can ever make the 
time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


Interesting article, though one thing that I'm confused by is

Hence D libraries remain inaccessible to C programs, and 
chimera programs (a mix of C and D) are not practical. One 
cannot pragmatically “try out” D by add D modules to an 
existing C program.


I've been mixing C and full D for a while now (on Linux) by 
either having the main C program call rt_init/rt_term directly 
(if druntime is linked in when building a mixed C/D application), 
or have Runtime.initialize/Runtime.terminate be called from D via 
some plugin_load/plugin_unload functionality when using D shared 
libraries.

Why is this not considered practical?


Re: @safe(bool)

2017-08-23 Thread 12345swordy via Digitalmars-d

On Wednesday, 23 August 2017 at 02:24:51 UTC, bitwise wrote:

On Tuesday, 22 August 2017 at 19:46:00 UTC, 12345swordy wrote:

On Tuesday, 22 August 2017 at 19:24:08 UTC, bitwise wrote:
On Tuesday, 22 August 2017 at 00:33:17 UTC, Jonathan M Davis 
wrote:

[...]

[...]


There was a time that people would write code with even 
modest performance requirements in assembler for fear of what 
the compiler would spit out, but that's in the past, as is 
the notion of trying to develop without an IDE.


You shouldn't rely on an IDE to compensate poor language 
design. That is coming from a guy who prefers IDE's.


Platitudes cause poor language design, not the completely 
reasonable expectation of good tools.


And who is "Platitude" here specifically?


Re: HTOD

2017-08-23 Thread 12345swordy via Digitalmars-d

On Tuesday, 22 August 2017 at 19:55:53 UTC, Jacob Carlborg wrote:

On 2017-08-22 19:47, 12345swordy wrote:


Use Clang frontend?


DStep [1] is doing that. It handles both GCC and Microsoft 
extensions.


[1] https://github.com/jacob-carlborg/dstep


"Doesn't translate C++ at all"

That's very disappointing. IMO, it should at least aim for the 
c++ 11 feature via using clang.


[Issue 17775] dmd master __VERSION__ should match the major release that it will be for

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

ZombineDev  changed:

   What|Removed |Added

 CC||petar.p.ki...@gmail.com

--- Comment #1 from ZombineDev  ---
This was changed in https://github.com/dlang/dmd/pull/6935.

--


D as a Better C

2017-08-23 Thread Mike Parker via Digitalmars-d-announce
To coincide with the improvements to -betterC in the upcoming DMD 
2.076, Walter has published a new article on the D blog about 
what it is and why to use it. A fun read. And I'm personally 
happy to see the love this feature is getting. I have a project 
I'd like to use it with if I can ever make the time for it!


The blog:

https://dlang.org/blog/2017/08/23/d-as-a-better-c/

Reddit:
https://www.reddit.com/r/programming/comments/6viswu/d_as_a_better_c/


Re: Long File path Exception:The system cannot find the path specified

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

On Wednesday, 23 August 2017 at 13:04:28 UTC, Vino.B wrote:


The line it complains is 
std.file.FileException@std\file.d(3713):even after enabling 
debug it points to the same


Output:
D:\DScript>rdmd -debug Test.d -r  dryrun

std.file.FileException@std\file.d(3713): 
N:\PROD_TEAM\TST_BACKUP\abcyf0\TST_BATS\j2ee_backup\cluster\states0\apps\bat.com\tc~bat~agent~application~e2emai~std~collectors\servlet_jsp\tc~bat~agent~application~e2emai~std~collectors\root\WEB-INF\entities\DataCollectionPushFileContentScannerTypeBuilder: The system cannot find the path specified.


0x00431A56
0x00429801


You need to compile with debug info (option `-g`), not compile in 
debug code (option `-debug`).

What's the (full) stack trace when compiling with debug info?


Re: fasta parser with iopipe?

2017-08-23 Thread Steven Schveighoffer via Digitalmars-d-learn

On 8/23/17 5:53 AM, biocyberman wrote:
I lost my momentum to learn D and want to gain it up again. Therefore I 
need some help with this seemingly simple task:


# Fasta sequence



\>Entry1_ID header field1|header field2|...
CAGATATCTTTGATGTCCTGATTGGAAGGACCGTTGGCCACCCTTAGGCAG
TGTATACTCTTCCATAAACGAGCTATTAGTTATGAGGTCCGTAGATTGGGG
TGACGGAATTCGGCCGAACGGGAAAGACGGACATCTAGGTATCCTGAGCACGGTT
GCGCGTCCGTATCAAGCTCCTCTTTATAGGG
\>Entry2_ID header field1|header field4|...
GTTACTGTTGGTCGTAGAGCCCAGAACGGGTTGGGCAGATGTACGACAATATCGCT
TAGTCACCCTTGGGCCACGGTCCGCTACCTTACAGGAATTGAGA



\>Entry3_ID header field1|header field2|...
GGCAGTACGATCGCACGACGTGAACGATTGGTAAACCCTGTGGCCTGTGAGC
GACGCTTTAATGGGAAATACGCGCCCATAACTTGGTGCGA


# Some characteristics:

- Entry_ID is >[[:alphanumeric:]]. Where '>' marks the entry start. In 
this post I have to put an escape character (\) to make the '>' visible.
- Headers may contain annotation information separated by some delimiter 
(i.e. | in this case).
- Entry ID and header is a single line, which does not contain newline 
characters.

- Sequence under the header line is [ATCGN\n]* (Perl regex).
- A fasta file can be plain-text or gzip compressed.


# Goals:
Write a parser that uses Dlang range with iopipe library for performance 
and ease of use. A big fasta file can be dozens of gigabytes.


# Questions:

1. How do I model a fasta entry with a struct or class?
2. How to I implement a range of fasta entries with iopipe. A range in 
this case can be a forward range, but preferably a random access range.
3. I want to do with range to explore the power and elegance of ranges. 
But if performance is a big concern, what can I do alternatively?


I'll respond to all your questions with what I would do, instead of 
answering each one.


I would suggest an approach similar to how I approached parsing JSON 
data. In your case, the protocol is even simpler, as there is no nesting.


1. The base layer iopipe should be something that tokenizes the input 
into reference-based structs. If you look at the jsoniopipe library 
(https://github.com/schveiguy/jsoniopipe), you can see that the lowest 
level finds the start of the next JSON token. In your case, it should be 
looking for >[[:alphanumeric:]] (or possibly just >).


This code is pretty straightforward, and roughly corresponds to this:
while(cannot find start sequence in stream)
stream.extend;
make sure you aren't re-doing work that has already been done (i.e. save 
the last place you looked).


Once you have this, you can deduce each packet by the data between the 
starts.


2. The next layer should validate and parse the data into structs that 
contain referencing data from the buffer. I recommend not using actual 
ranges from the buffer, but information on how to build the ranges. The 
reason for this is that the buffer can move while being streamed by 
iopipe, so your data could become invalid if you take actual references 
to the buffer. If you look in the jsoniopipe library, the struct for 
storing a json item has a start and length, but not a reference to the 
buffer.


Potentially, you could take this mechanism and build an iopipe on top of 
the buffered data. This iopipe's elements would be the items themselves, 
with the underlying buffer hidden in the implementation details. 
Extending would parse out another set of items, releasing would allow 
those items to get reclaimed (and the underlying stream data).


This is something I actually wanted to explore with jsoniopipe but 
didn't have time before the conference. I probably will still build it.


3. build your real code on top of that layer. What do you want to do 
with the data? Easiest thing to do for proof of concept is build a range 
out of the functions. That can allow you to test performance with your 
lower layers. One of the awesome things about iopipe is testing 
correctness is really easy -- every string is also an iopipe :)


I actually worked with a person at dconf on a similar (maybe identical?) 
format and explained how it could be done in a very similar way. He was 
looking to remove data that had a low percentage of correctness (or 
something like that, not in bioinformatics, so I don't understand the 
real semantics).


With this mechanism in hand, the decompression is pretty easy to chain 
together with whatever actual stream you have, just use iopipe.zip.


Good luck, and email me if you need more help (schvei...@yahoo.com).

-Steve


Re: Long File path Exception:The system cannot find the path specified

2017-08-23 Thread Vino.B via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 12:12:47 UTC, Moritz Maxeiner 
wrote:

On Wednesday, 23 August 2017 at 12:01:20 UTC, Vino.B wrote:
On Wednesday, 23 August 2017 at 11:29:07 UTC, Moritz Maxeiner 
wrote:


On which line do you get the Exception? Does it happen with 
shorter paths, as well?
Assuming it happens with all paths: Just to be sure, is each 
of those backslashes actually encoded as a backslash? If you 
specified the path in the D source like `path = 
"N:\PROD_TEAM..."`, then it won't be, because backslash is an 
escape character (you would need to write `path = 
"N:\\PROD_TEAM..."`, or better yet path = "N:/PROD_TEAM..."`).


  The above program scan for files/directories under the main 
folder N:\PROD_TEAM\ and reports the size of each of the sub 
folders eg: "TST_BACKUP", under the main folder 
"N:\PROD_TEAM\" there are more than 9000+ files/directories, 
eg: (N:\PROD_TEAM\TST_BACKUP,N:\PROD_TEAM\PRD_BACKUP\)  
and the above program will output the size of the sub folders 
"TST_BACKUP,PRD_BACKUP",  there is no issue is the path is 
shorter, the issue arises only when the path is bigger, eg the 
program prints the size of the sub folder PRD_BACKUP but when 
it tries to scan the sub folder TST_BACKUP the issue arises 
and the program terminates with the exception "The system 
cannot find the path specified", hence it not not be possible 
to provide the path explicitly, so can you help me on this.


While that is good to know, you still haven't answered my 
initial question:



On which line do you get the Exception?


If your program terminates because of an uncaught exception (as 
you stated), then you should've received a stack trace 
containing the line number on which the exception was thrown 
(remember to compile with debug info).
You should also consider providing a compilable, minimal 
example (with test data) that can be used to reproduce the 
issue.


The line it complains is std.file.FileException@std\file.d(3713): 
even after enabling debug it points to the same


Output:
D:\DScript>rdmd -debug Test.d -r  dryrun

std.file.FileException@std\file.d(3713): 
N:\PROD_TEAM\TST_BACKUP\abcyf0\TST_BATS\j2ee_backup\cluster\states0\apps\bat.com\tc~bat~agent~application~e2emai~std~collectors\servlet_jsp\tc~bat~agent~application~e2emai~std~collectors\root\WEB-INF\entities\DataCollectionPushFileContentScannerTypeBuilder: The system cannot find the path specified.


0x00431A56
0x00429801

From,
Vino.B


Re: DerelictGL3 reload crashes in 32 builds

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

On Tuesday, 22 August 2017 at 12:03:18 UTC, Igor wrote:


In the meantime can you tell me these two things:

1. How come DerelictGLES only has:
static if( Derelict_OS_Windows ) ...
else static if( Derelict_OS_Posix && !Derelict_OS_Mac )...
when GLES is primarily intended for mobile platforms as far as 
I know. What should I use for Android then?


I'm not sure what you're referring to. There are a few static 
if(Derelict_OS_Android) blocks in there as well.


That said, DerelictGLES is nowhere near ready for primetime. If 
you check the release list, there has been precisely one release: 
0.0.1 in July 2015, when I first added Windows support. Since 
then, I've made one commit to fix a bug.


The problem is the person who was the original maintainer hasn't 
been around in quite some time, I don't use OpenGL ES, and I've 
never touched the Android Developer Kit. The binding isn't even 
up to date with the latest DerelictUtil.


The Windows and Linux should both be working, buggy perhaps but 
usable. It's my intention to get it updated to the latest 
DerelictUtil at some point and test it across ANGLE, the AMD 
developer kit, and other implementations that exist, including 
MoltenGL on OS X. However, it is not a priority for me at all 
right now. Moreover, it's unlikely I'll ever touch the Android 
bits.


I'm happy to add anyone to DerelictOrg who is willing to take on 
the task of DerelictGLES maintenance.




2. I see that DerelictGL3 used to have wglext.d file where 
wglSwapIntervalEXT was loaded. How can I get access to this 
function now since I can't find it anywhere in the latest 
version?


Before I bring 2.0 out of beta, I will add support for 
platform-specific extensions via the existing mixin 
infrastructure. I'll also most likely add support for mixing in 
and loading the system API functions to completely eliminate the 
current link-time dependency for those who choose to use them.


Re: Parameter File reading

2017-08-23 Thread Seb via Digitalmars-d-learn

On Wednesday, 23 August 2017 at 10:25:48 UTC, Vino.B wrote:

Hi All,

  Can anyone provide me a example code on how to read a 
parameter file and use those parameter in the program.


From,
Vino.B


Another small library:

https://github.com/burner/inifiled


Re: DerelictGL3 reload crashes in 32 builds

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

On Tuesday, 22 August 2017 at 16:54:24 UTC, Igor wrote:

On Tuesday, 22 August 2017 at 12:03:18 UTC, Igor wrote:

On Monday, 21 August 2017 at 12:38:28 UTC, Mike Parker wrote:


Have you tried to compile outside of VisualD?


Hmmm... I though I tried running with just typing dub which 
should use m32 by default as far as I know and got the error. 
I will check one more time this evening. But LDC 32bit builds 
crash for sure. Note that I committed a version last night 
where I commented out the Derelict.reload call, so just make 
sure it is not commented before trying it out.


I must have remembered it wrong. I just tried it again and DMD 
32bit debug build works. It is DMD 32bit release build that is 
not working. When I run dub --build=release --force I get:

...
Error object.Error@(0): Access Violation

0x59BED731
0x5A6202C9 in wglGetProcAddress
0x004103B6
0x0040DC80
0x0040C691
Program exited with code 1


Apologies. Between the time I read your initial post and the time 
I tried to reproduce the issue, the fact that you explicitly 
mentioned it happens in release builds slipped my mind. I'm able 
to reproduce this. I've add a link to this thread in the issue 
report linked above. Please put future comments there. I'll set 
some time aside on Friday to see if I can sort this out. Thanks!


Re: Long File path Exception:The system cannot find the path specified

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

On Wednesday, 23 August 2017 at 05:06:50 UTC, Vino.B wrote:

Hi All,

  When i run the below code in windows i am getting "The system 
cannot find the path specified" even though the path exist , 
the length of the path is 516 as below, request your help.


Path :
N:\PROD_TEAM\TST_BACKUP\abcyf0\TST_BATS\j2ee_backup\cluster\states0\apps\bat.com\tc~bat~agent~application~e2emai~std~collectors\servlet_jsp\tc~bat~agent~application~e2emai~std~collectors\root\WEB-INF\entities\DataCollectionPushFileContentScannerTypeBuilder

Program:
void SizeDirList (string[] SzDNDlst)
{
 auto logF = File(LFpath, "a");
 ulong subdirTotal = 0;
 foreach (string i; SzDNDlst[0 .. $])
 {
  auto dFiles = dirEntries(i, SpanMode.shallow).filter!(a 
=> a.isDir && !globMatch(a.baseName, "*DND*")).array;

  foreach (d; dFiles)
{
auto SdFiles = dirEntries(d, 
SpanMode.breadth).array;
foreach (f; SdFiles)
{
subdirTotal += f.size;
}
   ulong subdirTotalGB = 
(subdirTotal/1024/1024/1024);
   if (subdirTotalGB > SizeDir)
{
writefln("%-63s %s", d, subdirTotalGB);
}
subdirTotal = 0;
}   
 }
}

From,
Vino.B


Windows has a 260-character limit on file path names. This can be 
disabled in Windows 10 for applications that ship with a 
manifest, but that isn't going to help you. If the Phobos 
functions are using the Win32 API internally, and specifically 
the Unicode variants, then you should be able to get around this 
by prepending "\\?" to any file path you send to the API. That's 
how long file paths have been handled in Win32 to date. If it 
doesn't work with Phobos, then you'll need to call Win32 directly 
and Phobos should be modified.


[Issue 17775] New: dmd master __VERSION__ should match the major release that it will be for

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

  Issue ID: 17775
   Summary: dmd master __VERSION__ should match the major release
that it will be for
   Product: D
   Version: D2
  Hardware: All
OS: All
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: dmd
  Assignee: nob...@puremagic.com
  Reporter: issues.dl...@jmdavisprog.com

Right now, it seems that the way that dmd version number is handled is that it
matches the current major release and gets bumped when another major release is
made. So, if 2.075 is the current major release, then dmd --version with dmd
master prints something like

DMD64 D Compiler DMD64 D Compiler v2.075.0-336-g12fa5f06c

and __VERSION__ is 2075. The main problem that I see with this is that if a
change is made in master, and a project wants to / needs to version code
differently based on whether it's building with master or something older,
there's no way to do it, because __VERSION__ is the same for both, whereas if
master had the version number of the release that will come from it next rather
than the release that came from it last, then no such problem exists. And since
minor releases are released from the stable branch rather than master, having
master be a higher version number than what the minor release will have
shouldn't matter, and the higher version that master does have will match what
the next major release is. So, it can just be bumped after the new branch for
the next release is made rather than being bumped right before it's made, which
seems to be how it works now.

What we have right now seems to manage to make sure that the releases have the
right version, but it doesn't play well at all for using __VERSION__ when you
need to differentiate from master.

--


Re: Long File path Exception:The system cannot find the path specified

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

On Wednesday, 23 August 2017 at 12:01:20 UTC, Vino.B wrote:
On Wednesday, 23 August 2017 at 11:29:07 UTC, Moritz Maxeiner 
wrote:


On which line do you get the Exception? Does it happen with 
shorter paths, as well?
Assuming it happens with all paths: Just to be sure, is each 
of those backslashes actually encoded as a backslash? If you 
specified the path in the D source like `path = 
"N:\PROD_TEAM..."`, then it won't be, because backslash is an 
escape character (you would need to write `path = 
"N:\\PROD_TEAM..."`, or better yet path = "N:/PROD_TEAM..."`).


  The above program scan for files/directories under the main 
folder N:\PROD_TEAM\ and reports the size of each of the sub 
folders eg: "TST_BACKUP", under the main folder "N:\PROD_TEAM\" 
there are more than 9000+ files/directories, eg: 
(N:\PROD_TEAM\TST_BACKUP,N:\PROD_TEAM\PRD_BACKUP\)  and the 
above program will output the size of the sub folders 
"TST_BACKUP,PRD_BACKUP",  there is no issue is the path is 
shorter, the issue arises only when the path is bigger, eg the 
program prints the size of the sub folder PRD_BACKUP but when 
it tries to scan the sub folder TST_BACKUP the issue arises and 
the program terminates with the exception "The system cannot 
find the path specified", hence it not not be possible to 
provide the path explicitly, so can you help me on this.


While that is good to know, you still haven't answered my initial 
question:



On which line do you get the Exception?


If your program terminates because of an uncaught exception (as 
you stated), then you should've received a stack trace containing 
the line number on which the exception was thrown (remember to 
compile with debug info).
You should also consider providing a compilable, minimal example 
(with test data) that can be used to reproduce the issue.


Re: ore.exception.RangeError

2017-08-23 Thread Vino.B via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 11:18:14 UTC, Moritz Maxeiner 
wrote:

On Wednesday, 23 August 2017 at 05:53:46 UTC, ag0aep6g wrote:

On 08/23/2017 07:45 AM, Vino.B wrote:

Execution :
rdmd Summary.d - Not working
rdmd Summary.d test - Working

Program:

void main (string[] args)
{
  if(args.length != 2 )
 writefln("Unknown operation: %s", args[1]);
}


When args.length == 1, then the one element is args[0], not 
args[1].


args[1] only exists when args.length >= 2.


To expand on that: argv[0] is what is passed to the process the 
D program runs at in the system call it was spawned from (e.g. 
execve), which usually corresponds to the program's name.


Hi All,

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

From,
Vino.B


Re: Long File path Exception:The system cannot find the path specified

2017-08-23 Thread Vino.B via Digitalmars-d-learn
On Wednesday, 23 August 2017 at 11:29:07 UTC, Moritz Maxeiner 
wrote:

On Wednesday, 23 August 2017 at 05:06:50 UTC, Vino.B wrote:

Hi All,

  When i run the below code in windows i am getting "The 
system cannot find the path specified" even though the path 
exist , the length of the path is 516 as below, request your 
help.


Path :
N:\PROD_TEAM\TST_BACKUP\abcyf0\TST_BATS\j2ee_backup\cluster\states0\apps\bat.com\tc~bat~agent~application~e2emai~std~collectors\servlet_jsp\tc~bat~agent~application~e2emai~std~collectors\root\WEB-INF\entities\DataCollectionPushFileContentScannerTypeBuilder

Program:
[...]


On which line do you get the Exception? Does it happen with 
shorter paths, as well?
Assuming it happens with all paths: Just to be sure, is each of 
those backslashes actually encoded as a backslash? If you 
specified the path in the D source like `path = 
"N:\PROD_TEAM..."`, then it won't be, because backslash is an 
escape character (you would need to write `path = 
"N:\\PROD_TEAM..."`, or better yet path = "N:/PROD_TEAM..."`).


Hi,

  The above program scan for files/directories under the main 
folder N:\PROD_TEAM\ and reports the size of each of the sub 
folders eg: "TST_BACKUP", under the main folder "N:\PROD_TEAM\" 
there are more than 9000+ files/directories, eg: 
(N:\PROD_TEAM\TST_BACKUP,N:\PROD_TEAM\PRD_BACKUP\)  and the 
above program will output the size of the sub folders 
"TST_BACKUP,PRD_BACKUP",  there is no issue is the path is 
shorter, the issue arises only when the path is bigger, eg the 
program prints the size of the sub folder PRD_BACKUP but when it 
tries to scan the sub folder TST_BACKUP the issue arises and the 
program terminates with the exception "The system cannot find the 
path specified", hence it not not be possible to provide the path 
explicitly, so can you help me on this.


From,
Vino.B


Re: Long File path Exception:The system cannot find the path specified

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

On Wednesday, 23 August 2017 at 05:06:50 UTC, Vino.B wrote:

Hi All,

  When i run the below code in windows i am getting "The system 
cannot find the path specified" even though the path exist , 
the length of the path is 516 as below, request your help.


Path :
N:\PROD_TEAM\TST_BACKUP\abcyf0\TST_BATS\j2ee_backup\cluster\states0\apps\bat.com\tc~bat~agent~application~e2emai~std~collectors\servlet_jsp\tc~bat~agent~application~e2emai~std~collectors\root\WEB-INF\entities\DataCollectionPushFileContentScannerTypeBuilder

Program:
[...]


On which line do you get the Exception? Does it happen with 
shorter paths, as well?
Assuming it happens with all paths: Just to be sure, is each of 
those backslashes actually encoded as a backslash? If you 
specified the path in the D source like `path = 
"N:\PROD_TEAM..."`, then it won't be, because backslash is an 
escape character (you would need to write `path = 
"N:\\PROD_TEAM..."`, or better yet path = "N:/PROD_TEAM..."`).


[Issue 17774] New: Please include implib in setup / 7z archive

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

  Issue ID: 17774
   Summary: Please include implib in setup / 7z archive
   Product: D
   Version: D2
  Hardware: x86
OS: Windows
Status: NEW
  Severity: enhancement
  Priority: P1
 Component: installer
  Assignee: nob...@puremagic.com
  Reporter: an...@s-e-a-p.de

Please include implib.exe in Windows exe / 7z archive file.
Without implib you can't use e.g. SQLite with DMD x86.

--


Re: ore.exception.RangeError

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

On Wednesday, 23 August 2017 at 05:53:46 UTC, ag0aep6g wrote:

On 08/23/2017 07:45 AM, Vino.B wrote:

Execution :
rdmd Summary.d - Not working
rdmd Summary.d test - Working

Program:

void main (string[] args)
{
  if(args.length != 2 )
 writefln("Unknown operation: %s", args[1]);
}


When args.length == 1, then the one element is args[0], not 
args[1].


args[1] only exists when args.length >= 2.


To expand on that: argv[0] is what is passed to the process the D 
program runs at in the system call it was spawned from (e.g. 
execve), which usually corresponds to the program's name.


Re: Parameter File reading

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

On Wednesday, 23 August 2017 at 10:25:48 UTC, Vino.B wrote:

Hi All,

  Can anyone provide me a example code on how to read a 
parameter file and use those parameter in the program.


From,
Vino.B


For small tools I use JSON files via asdf[1].
As an example you can look at the tunneled settings structure 
here[2] and how it's loaded and parsed here[3]; afterwards, you 
just use the struct as normal in D.


[1] https://github.com/tamediadigital/asdf
[2] 
https://github.com/Calrama/tunneled/blob/master/source/tunneled.d#L3
[3] 
https://github.com/Calrama/tunneled/blob/master/source/tunneled.d#L45


Re: Static inline field initialization

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

On Wednesday, 23 August 2017 at 09:12:19 UTC, Kagamin wrote:
On Tuesday, 22 August 2017 at 16:28:43 UTC, Moritz Maxeiner 
wrote:

class Test
{
ubyte[] buf = new ubyte[1000]; // thread local storage, 
instances in the same thread refer to the same static array

}


Dynamic initialization is done by constructor:

[...]

It's also unambiguous as to how it works.


I am aware, as I have pointed out the same in the above, but the 
post you quote is explicitly not about dynamic initialization 
(i.e. the result of new points into the heap), but about static 
initialization (the result of new points into sections of the 
binary format).
Specifically, it's about static initialization done for variables 
put into classic global storage (e.g. ELF sections .data/.bss) 
and variables put into thread local storage (e.g. ELF sections 
.tdata/.tbss).


Re: fasta parser with iopipe?

2017-08-23 Thread Nicholas Wilson via Digitalmars-d-learn

On Wednesday, 23 August 2017 at 09:53:49 UTC, biocyberman wrote:
I lost my momentum to learn D and want to gain it up again. 
Therefore I need some help with this seemingly simple task:


# Fasta sequence



\>Entry1_ID header field1|header field2|...
CAGATATCTTTGATGTCCTGATTGGAAGGACCGTTGGCCACCCTTAGGCAG
TGTATACTCTTCCATAAACGAGCTATTAGTTATGAGGTCCGTAGATTGGGG
TGACGGAATTCGGCCGAACGGGAAAGACGGACATCTAGGTATCCTGAGCACGGTT
GCGCGTCCGTATCAAGCTCCTCTTTATAGGG
\>Entry2_ID header field1|header field4|...
GTTACTGTTGGTCGTAGAGCCCAGAACGGGTTGGGCAGATGTACGACAATATCGCT
TAGTCACCCTTGGGCCACGGTCCGCTACCTTACAGGAATTGAGA



\>Entry3_ID header field1|header field2|...
GGCAGTACGATCGCACGACGTGAACGATTGGTAAACCCTGTGGCCTGTGAGC
GACGCTTTAATGGGAAATACGCGCCCATAACTTGGTGCGA


# Some characteristics:

- Entry_ID is >[[:alphanumeric:]]. Where '>' marks the entry 
start. In this post I have to put an escape character (\) to 
make the '>' visible.
- Headers may contain annotation information separated by some 
delimiter (i.e. | in this case).
- Entry ID and header is a single line, which does not contain 
newline characters.

- Sequence under the header line is [ATCGN\n]* (Perl regex).


(if you know your sequence has no Ns or other ambiguous bases you 
can can store 4 bases to a byte, or 3 if you want them in 
triplets)



- A fasta file can be plain-text or gzip compressed.


# Goals:
Write a parser that uses Dlang range with iopipe library for 
performance and ease of use. A big fasta file can be dozens of 
gigabytes.


# Questions:

1. How do I model a fasta entry with a struct or class?


You could model the headers as a struct if you know the format, 
but most of the time I think they are just ignored, if you really 
need them just put them in a string[string].
The real info is in the sequences which are just a string of 
characters (not utf-8 so i'd go with ubyte or some compressed 
form).


id go with

struct FastaEntry
{
string id;
string[string] headers;
ubyte[] sequence;
}

and the a fasta is an array of entries. Note that with the 
expected usage patterns you probably want this in struct of array 
(SoA) form (see https://maikklein.github.io/post/soa-d/) given 
unless you're bring it out you're unlike likely to need more than 
one field at a time.


2. How to I implement a range of fasta entries with iopipe. A 
range in this case can be a forward range, but preferably a 
random access range.


Given the relative simplicity of the file format I'm don't think 
it should be too hard. iopipe would give you a streaming 
interface for it that would work with gzip compression but 
wouldn't get you a random access range. You can keep the most 
recent entries for look back but for real random access (e.g. if 
you're trying to align them) you need them all in an array see 
above comment about SoA .


3. I want to do with range to explore the power and elegance of 
ranges. But if performance is a big concern, what can I do 
alternatively?


You can probably use it for parsing I'd take a look at the 
https://github.com/schveiguy/iopipe documentation and see what 
you can find.


OT, I'm taking "systems biology and bioinformatics" this semester 
so I'll be very interested to see what you do. Partly for the 
bioinformatics stuff but also I will be giving a (series I hope) 
of talks to the staff and some students at my university about 
computation for biology (rather introductory as is the biology 
department) but still I hope to get them interested in 
computational biology and D so if you have some good examples 
please do let me know.


Nic



[Issue 6033] Better error message with numbers with leading zeros

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

RazvanN  changed:

   What|Removed |Added

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

--- Comment #2 from RazvanN  ---
Running this code on ubuntu 16.04 64-bit with git HEAD results in successful
compilation. The 09 is treated as integral 9. Closing as fixed.

--


Parameter File reading

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

Hi All,

  Can anyone provide me a example code on how to read a parameter 
file and use those parameter in the program.


From,
Vino.B




[Issue 17604] Reject mutable fields initialized with reference types to data segment

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

--- Comment #5 from anonymous4  ---
(In reply to Vladimir Panteleev from comment #3)
> I prefer the description on this bug but I'm a little biased ;)

This scenario needs dynamic initialization, and D requires an explicit
constructor for it for whatever reason, so disallowing is the the most
straightforward solution.

--


fasta parser with iopipe?

2017-08-23 Thread biocyberman via Digitalmars-d-learn
I lost my momentum to learn D and want to gain it up again. 
Therefore I need some help with this seemingly simple task:


# Fasta sequence



\>Entry1_ID header field1|header field2|...
CAGATATCTTTGATGTCCTGATTGGAAGGACCGTTGGCCACCCTTAGGCAG
TGTATACTCTTCCATAAACGAGCTATTAGTTATGAGGTCCGTAGATTGGGG
TGACGGAATTCGGCCGAACGGGAAAGACGGACATCTAGGTATCCTGAGCACGGTT
GCGCGTCCGTATCAAGCTCCTCTTTATAGGG
\>Entry2_ID header field1|header field4|...
GTTACTGTTGGTCGTAGAGCCCAGAACGGGTTGGGCAGATGTACGACAATATCGCT
TAGTCACCCTTGGGCCACGGTCCGCTACCTTACAGGAATTGAGA



\>Entry3_ID header field1|header field2|...
GGCAGTACGATCGCACGACGTGAACGATTGGTAAACCCTGTGGCCTGTGAGC
GACGCTTTAATGGGAAATACGCGCCCATAACTTGGTGCGA


# Some characteristics:

- Entry_ID is >[[:alphanumeric:]]. Where '>' marks the entry 
start. In this post I have to put an escape character (\) to make 
the '>' visible.
- Headers may contain annotation information separated by some 
delimiter (i.e. | in this case).
- Entry ID and header is a single line, which does not contain 
newline characters.

- Sequence under the header line is [ATCGN\n]* (Perl regex).
- A fasta file can be plain-text or gzip compressed.


# Goals:
Write a parser that uses Dlang range with iopipe library for 
performance and ease of use. A big fasta file can be dozens of 
gigabytes.


# Questions:

1. How do I model a fasta entry with a struct or class?
2. How to I implement a range of fasta entries with iopipe. A 
range in this case can be a forward range, but preferably a 
random access range.
3. I want to do with range to explore the power and elegance of 
ranges. But if performance is a big concern, what can I do 
alternatively?





[Issue 17666] std.c.linux.socket has no replacement

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

--- Comment #7 from Jonathan M Davis  ---
(In reply to Sebastiaan Koppe from comment #6)
> Ok, great. Whenever I get some time I will check core.sys.freebsd.inet.in_,
> core.sys.linux.inet.in_, and core.sys.darwin.inet.in_ to see if I see
> something missing, and add them in that case.

I added basically everything that was in those header files except for
declarations that were indicated by one of the systems to be deprecated or
obsolete. So, while I certainly could have screwed up and missed something, and
there may be some debate about a few of the items I intentionally skipped, I
find it unlikely that anything that you care about will be missing. The bigger
issue is the declarations in std.c.linux.socket which don't come from
netinet/in.h, since that's the only header I've done anything for thus far.
Most of what was in there was in netinet/in.h, but not all of it.

--


Re: Static inline field initialization

2017-08-23 Thread Kagamin via Digitalmars-d

On Tuesday, 22 August 2017 at 16:28:43 UTC, Moritz Maxeiner wrote:

class Test
{
ubyte[] buf = new ubyte[1000]; // thread local storage, 
instances in the same thread refer to the same static array

}


Dynamic initialization is done by constructor:

class Test
{
static ubyte[1000] s;
ubyte[] buf;
this()
{
buf=s;
}
}

It's also unambiguous as to how it works.


Re: HTOD

2017-08-23 Thread Sebastiaan Koppe via Digitalmars-d

On Tuesday, 22 August 2017 at 22:50:46 UTC, Walter Bright wrote:

On 8/22/2017 2:50 PM, Steven Schveighoffer wrote:

But it is generating D code, no?


Sure. And the C subset of D has been very stable, too.


Used the tool 2 years ago. Worked like a charm.


[Issue 9631] Error message not using fully qualified name when appropriate.

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

Mike  changed:

   What|Removed |Added

   Keywords|trivial |
 CC||slavo5...@yahoo.com

--


[Issue 17666] std.c.linux.socket has no replacement

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

--- Comment #6 from Sebastiaan Koppe  ---
Ok, great. Whenever I get some time I will check core.sys.freebsd.inet.in_,
core.sys.linux.inet.in_, and core.sys.darwin.inet.in_ to see if I see something
missing, and add them in that case.

--


  1   2   >