How to use xargs to remove whitespaces (Dub executable path)

2019-09-03 Thread Andre Pany via Digitalmars-d-learn

Hi,

I try to get the executable path from a dub package using this 
command:


dub describe dscanner --data=target-path,target-name --data-list 
| xargs


But the output always contains a space between target-path and 
target-name:

/home/user/.dub/packages/dscanner-0.8.0/dscanner/bin/ dscanner

How can I get the full path without a space on a debian system in 
a 1 liner?


Kind regards
André




Re: Is there has an pdf document for Phobos.

2019-09-03 Thread Mike Parker via Digitalmars-d-learn

On Wednesday, 4 September 2019 at 03:07:18 UTC, lili wrote:

Hi:
   For some reason it too slow that some times i visited 
dlang.org, Can admin make a pdf document for download.


Documentation is installed with the compiler.


Is there has an pdf document for Phobos.

2019-09-03 Thread lili via Digitalmars-d-learn

Hi:
   For some reason it too slow that some times i visited 
dlang.org, Can admin make a pdf document for download.


Re: problems with swig generated code

2019-09-03 Thread Laeeth Isharc via Digitalmars-d-learn
On Tuesday, 3 September 2019 at 20:03:37 UTC, Martin DeMello 
wrote:

On Sunday, 1 September 2019 at 11:19:11 UTC, DanielG wrote:
Do you know whether SWIG's D generator is even being 
maintained?


I've searched for it on the forums in the past and got the 
impression that it's outdated.


I didn't realise that :( It was included in the current release 
of swig, so I figured it was maintained.


It's pretty sad if it's not, because trying to access C++ 
libraries directly from D has some limitations (most notably 
not being able to create new C++ objects from D) and swig would 
have let things just work.


I think DPP can call constructors. YMMV.

We are working on a little project I started as another step in 
the eternal personal hackathon.


Libclang isn't my cup of tea.  It's almost very cool but they put 
in whatever the guy needed and so it's inconsistent but your 
alternative is code that breaks things between breakfast and 
teatime.


Cling is used at CERN and I found libcling more pleasant.  I only 
wrapped the cppyy fork but that actually allows you to reflect at 
runtime on a lot.  From our DSL at work I can include a header, 
instantiate a templated type, create an instance of the class and 
call a method on it.  Can, but it's not what I would call fun.


I didn't yet get time to wrap the rest of the interpreter.

But the idea is to make a tool for wrapping c++ via simpler 
extern (C++).  If one isn't quite sure upfront what will work and 
not then it's much more pragmatic.  I can't see how it won't work 
but we will know in a week or two.


My first version is here.

https://github.com/kaleidicassociates/cpp-reflect-d

There is another route people don't think of.  Calypso can 
introspect on C++ too.  You might not want to use it in 
production but you don't need to.  Either I guess you could use 
it to generate wrappers or you can use it to replace a chunk of 
cpp code.


The surface area of a method must be larger than thr surface area 
of a chunk.  Well chosen then it's easy to write glue code semi 
automatically.  But it's nice to be able to replace a method at a 
time and have working code at every step.


You don't need to trust Calypso in production to be able to use 
it for this purpose.


Re: Is removing elements of AA in foreach loop safe?

2019-09-03 Thread Ferhat Kurtulmuş via Digitalmars-d-learn

On Thursday, 29 August 2019 at 10:11:58 UTC, berni wrote:
Iterating of some structure and removing elements thereby is 
always errorprone and should be avoided. But: In case of AA, 
I've got the feeling, that it might be safe:



foreach (k,v;ways)
if (v.empty)
ways.remove(k);


Do you agree? Or is there a better way to achieve this?


I know, it is foreach loop in question. How about using a reverse 
for loop like:


for (size_t i = arr.length ; i-- > 0 ; ){
arr.remove(i);
}


Re: problems with swig generated code

2019-09-03 Thread Martin DeMello via Digitalmars-d-learn

On Sunday, 1 September 2019 at 11:19:11 UTC, DanielG wrote:

Do you know whether SWIG's D generator is even being maintained?

I've searched for it on the forums in the past and got the 
impression that it's outdated.


I didn't realise that :( It was included in the current release 
of swig, so I figured it was maintained.


It's pretty sad if it's not, because trying to access C++ 
libraries directly from D has some limitations (most notably not 
being able to create new C++ objects from D) and swig would have 
let things just work.


Re: adding delegate to opApply

2019-09-03 Thread berni via Digitalmars-d-learn

On Monday, 2 September 2019 at 14:20:11 UTC, Paul Backus wrote:

If you have an existing delegate that you want to use with 
opApply, the easiest way is like this:


void delegate(Thing) myDelegate = ...;

foreach(thing; things) {
myDelegate(thing);
}
// Equivalent to: things.opApply((Thing t) => myDelegate(t))


Thanks for your answer. It's not exactly, what I was looking for, 
but meanwhile I think, the whole idea was not reasonable. I 
meanwhile returned to using a normal function call instead of 
opApply, which makes it easy to pass a delegate as one of the 
parameters.


Re: Why is sformat and formattedWrite (appender) allocating GC mem here?

2019-09-03 Thread ag0aep6g via Digitalmars-d-learn

On 03.09.19 16:03, James Blachly wrote:
For my own learning, why was a unittest to ensure no GC added to sformat 
instead of a @nogc annotation?


`sformat` uses the GC less now, but it's not @nogc. It can still throw 
GC-allocated exceptions, e.g. when the arguments don't match the format 
string.


Re: Why is sformat and formattedWrite (appender) allocating GC mem here?

2019-09-03 Thread James Blachly via Digitalmars-d-learn

On 8/31/19 5:12 PM, ag0aep6g wrote:

I've made a pull request to get rid of those allocations:
https://github.com/dlang/phobos/pull/7163


Wonderful!
For my own learning, why was a unittest to ensure no GC added to sformat 
instead of a @nogc annotation?


Re: How stdin.readf ignore space char?

2019-09-03 Thread a11e99z via Digitalmars-d-learn

On Tuesday, 3 September 2019 at 13:25:30 UTC, lili wrote:

On Tuesday, 3 September 2019 at 13:21:16 UTC, a11e99z wrote:

On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote:


string d = "3.43.3 ";
double a;
double b;

//formattedRead(d,"%f %f", , );

d.readf!" %s %s"(a,b);//hug
writeln(a,b);


and this too

string ds = "1.1 2.2 3.3";
double[] darr;
ds.formattedRead!"%( %s%)"( darr );
darr.writeln;


Re: How stdin.readf ignore space char?

2019-09-03 Thread a11e99z via Digitalmars-d-learn

On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote:

Hi guys:

   input is two line, first line is a number n and second line 
is n float point number,

e.g. 3
 1.1 2.2 3.3
how use stdin.readf get all number.


u can read array this way too

auto darr = readln.split.map!(x => x.to!double).array;
darr.writeln;




Re: How stdin.readf ignore space char?

2019-09-03 Thread lili via Digitalmars-d-learn

On Tuesday, 3 September 2019 at 13:21:16 UTC, a11e99z wrote:

On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote:

Hi guys:

   input is two line, first line is a number n and second line 
is n float point number,

e.g. 3
 1.1 2.2 3.3
how use stdin.readf get all number.


https://dlang.org/library/std/stdio/readf.html
see example


string d = "3.43.3 ";
double a;
double b;

//formattedRead(d,"%f %f", , );

d.readf!" %s %s"(a,b);//hug
writeln(a,b);



Re: How stdin.readf ignore space char?

2019-09-03 Thread a11e99z via Digitalmars-d-learn

On Tuesday, 3 September 2019 at 12:55:29 UTC, lili wrote:

Hi guys:

   input is two line, first line is a number n and second line 
is n float point number,

e.g. 3
 1.1 2.2 3.3
how use stdin.readf get all number.


https://dlang.org/library/std/stdio/readf.html
see example


How stdin.readf ignore space char?

2019-09-03 Thread lili via Digitalmars-d-learn

Hi guys:

   input is two line, first line is a number n and second line is 
n float point number,

e.g. 3
 1.1 2.2 3.3
how use stdin.readf get all number. i code below but not work 
well.


int n;
stdin.readf!"%d\n"(n);
writeln("read n:",n);

foreach (i; 0..n)
{
double x;
stdin.readf!"%f"(x); //only return first number, 
why?

writeln(x);
}



Blog Post #67 - Expander

2019-09-03 Thread Ron Tarrant via Digitalmars-d-learn
Today's post covers the Expander, a widget that... well... 
expands to reveal things hidden within. It's not quite a 
TreeView, but it's also a lot easier to use. You can read all 
about it here: 
https://gtkdcoding.com/2019/09/03/0067-mvc-xii-expander.html


Re: Linking D Runtime

2019-09-03 Thread Jacob Carlborg via Digitalmars-d-learn

On 2019-09-03 03:45, Jonathan Levi wrote:

It looks like what needs to be found are "libphobos2" and 
"libdruntime".  They can be found where ever your system puts lib 
files.  Windows (as far as I know) does not have a joined place for lib 
files so you need to look where dmd/ldc/etc installed itself.  On Linux 
lib files are generally put in `/usr/lib`. Ideally the hunting for lib 
files should be left to a build tool in order to be system agnostic.  In 
Cabal (Haskell's build tool) add "druntime" and "phobos2" to 
`extra-libraries`.


This depends on how the compiler is installed. There are several 
installers that do not put the libraries in `/usr/lib`. BTW, that 
directory doesn't exist by default anymore on macOS, even if Xcode and 
the command line tools are installed.


--
/Jacob Carlborg


Re: Linking D Runtime

2019-09-03 Thread Jacob Carlborg via Digitalmars-d-learn

On 2019-09-03 10:43, Jacob Carlborg wrote:

This depends on how the compiler is installed. There are several 
installers that do not put the libraries in `/usr/lib`. BTW, that 
directory doesn't exist by default anymore on macOS, even if Xcode and 
the command line tools are installed.


My bad. "/usr/lib" exists, it's "/usr/include" that usually doesn't exist.

--
/Jacob Carlborg


Re: Linking D Runtime

2019-09-03 Thread sarn via Digitalmars-d-learn

On Saturday, 24 August 2019 at 02:10:19 UTC, Jonathan Levi wrote:
I would love a more portable solution though.  This should work 
for now.


How are you building the D code?  It should be possible to build 
a library (with -lib and/or -shared) that statically includes the 
runtime and Phobos.


If you want to dynamically link the standard libraries, then you 
shouldn't need to specify the full path (just "phobos2" and 
"druntime") as long as they're installed in one of the system's 
library search paths (see /etc/ld.so.conf on GNU/Linux).


I'm fucking tired of this shit... Why doesn't Visual D install ?

2019-09-03 Thread Enjoys Math via Digitalmars-d-learn
It says right on the front page of it, that it installs in 2019.  
I of course have the C++ tools installed already because I was 
doing C++ dev in Qt and needed to.  Where's the Visual D menu?  
Where are the project types?


This fucking sucks.  Every time I think oh, I could use D on 
that, it would be perfect... it NEVER FUCKING WORKS.


Fuck this shit.