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

2019-09-04 Thread Les De Ridder via Digitalmars-d-learn

On Wednesday, 4 September 2019 at 08:23:19 UTC, Andre Pany wrote:
On Wednesday, 4 September 2019 at 06:40:13 UTC, H. S. Teoh 
wrote:
On Wed, Sep 04, 2019 at 05:52:12AM +, Andre Pany via 
Digitalmars-d-learn wrote:

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?

[...]

Try:
... | sed -e's@ @@g'


T


Thanks a lot. Works fine:)
dub describe dscanner --data=target-path,target-name 
--data-list | xargs | sed -e's@ @@g'


It's better to only replace the last occurrence, so it won't 
break on

paths containing spaces:

... | sed 's/\(.*\) /\1/'

There should probably just be a switch to use NUL characters as 
the

delimiter though.




Re: Static initialization of rectangular arrays

2019-08-29 Thread Les De Ridder via Digitalmars-d-learn

On Thursday, 29 August 2019 at 15:10:26 UTC, rombankzero wrote:

[...]

Is this a bug, or am I missing something? It would be really 
convenient to be able to statically initialize rectangular 
arrays in this way. Example: I have a struct that has a member 
that's a rectangular float array, but I have no way of telling 
the compiler that I want it default-initialized to all-zeroes 
(instead of NaNs)!


It's a known bug[1].

As a workaround you could use a `static this()`:

static double[6][3] matrix;

static this()
{
matrix = 0;
}

[1] https://issues.dlang.org/show_bug.cgi?id=19178


Re: Files as buffered InputRange

2019-07-05 Thread Les De Ridder via Digitalmars-d-learn

On Friday, 5 July 2019 at 18:29:36 UTC, berni wrote:

On Friday, 5 July 2019 at 17:57:39 UTC, Les De Ridder wrote:

File.byChunk[1] should do the trick.

[1] https://dlang.org/library/std/stdio/file.by_chunk.html


Not sure, if this is, what I'm looking for. I'd like to do 
something like



buffered_file.map!(a=>2*a).writeln();


When I understand it right, with byChunk I'll have to take care 
about the end of the buffer, myself...


You could use `joiner` from std.algorithm, e.g.
buffered_file.byChunk(4096).joiner.map!(a => 2 * a).writeln;


Re: Files as buffered InputRange

2019-07-05 Thread Les De Ridder via Digitalmars-d-learn

On Friday, 5 July 2019 at 17:29:26 UTC, berni wrote:
I'd like to process a (binary) file as a buffered InputRange 
but I havn't found anything yet.  Is there anything or do I 
have to write it on my own?


File.byChunk[1] should do the trick.

[1] https://dlang.org/library/std/stdio/file.by_chunk.html


Re: How to build a package as application ?

2019-07-02 Thread Les De Ridder via Digitalmars-d-learn

On Tuesday, 2 July 2019 at 17:29:51 UTC, guiguidu60 wrote:

On Tuesday, 2 July 2019 at 17:14:23 UTC, Les De Ridder wrote:

On Tuesday, 2 July 2019 at 16:56:52 UTC, guiguidu60 wrote:

On Tuesday, 2 July 2019 at 16:44:12 UTC, Les De Ridder wrote:

On Tuesday, 2 July 2019 at 14:49:49 UTC, guiguidu60 wrote:

[...]


What file manager are you using?

Could you perhaps upload an example binary that gets 
detected wrong?


I'm on Debian 10, with Nautilus (v3.30.5) as file explorer.
You can download the helloworld program with this link: 
https://mega.nz/#!rY1QWIhK!lKyIX192OEfKM8MsZ_WW_QNryl39yCQebkXts2qn7E0


As I suspected, it's because it's a PIE executable, so this 
issue is

not specific to D.

Going down the rabbit hole:
https://bugzilla.gnome.org/show_bug.cgi?id=737849
https://bugs.freedesktop.org/show_bug.cgi?id=97226
https://gitlab.freedesktop.org/xdg/shared-mime-info/issues/11


Ahh ok, thanks !
The bug is old... how can I develop D applications without 
having to suffer this bug ?


Currently you can't, AFAICT.

Many Linux distros these days make PIE the default for Clang/GCC,
because PIE allows for more ASLR, a common modern security 
hardening

measure.

Because D uses the C compiler to link your application, this 
default

will be passed down to the linker. Because of the order in which D
passes args down to the linker, there doesn't seem to be a way to
override this (unless you link manually, e.g. by appending 
`-no-pie` to

the clang/gcc command you get with `dmd -v `).

It might make sense to change dmd's behaviour so it explicitly 
passes
`-no-pie` to the C compiler when it's not being called with 
`-fPIC`.


In any case, the bug is still not D's fault and will also occur 
with

e.g. C programs compiled without `-no-pie` (and probably most
executables in /usr/bin!).


Re: How to build a package as application ?

2019-07-02 Thread Les De Ridder via Digitalmars-d-learn

On Tuesday, 2 July 2019 at 16:56:52 UTC, guiguidu60 wrote:

On Tuesday, 2 July 2019 at 16:44:12 UTC, Les De Ridder wrote:

On Tuesday, 2 July 2019 at 14:49:49 UTC, guiguidu60 wrote:

On Tuesday, 2 July 2019 at 10:43:08 UTC, Andre Pany wrote:

On Tuesday, 2 July 2019 at 08:50:36 UTC, guiguidu60 wrote:

I'm a newbie with D language, and my first problem ever is:

I have a hello world program build with DUB on Linux, but 
the program as marked as "application/x-sharedlib" and not 
"application/x-executable" (in properties of the file): so, 
I can't able to execute the program from the file explorer 
(need to do ./helloworld within a terminal).


Executable is automatically chosen if you have a source code 
file with name "app.d".

Otherwise set targetType to executable in your dub.json.

Kind regards
André


It doesn't work...
Who decide if a file is an application or a sharedlib ?


What file manager are you using?

Could you perhaps upload an example binary that gets detected 
wrong?


I'm on Debian 10, with Nautilus (v3.30.5) as file explorer.
You can download the helloworld program with this link: 
https://mega.nz/#!rY1QWIhK!lKyIX192OEfKM8MsZ_WW_QNryl39yCQebkXts2qn7E0


As I suspected, it's because it's a PIE executable, so this issue 
is

not specific to D.

Going down the rabbit hole:
https://bugzilla.gnome.org/show_bug.cgi?id=737849
https://bugs.freedesktop.org/show_bug.cgi?id=97226
https://gitlab.freedesktop.org/xdg/shared-mime-info/issues/11


Re: How to build a package as application ?

2019-07-02 Thread Les De Ridder via Digitalmars-d-learn

On Tuesday, 2 July 2019 at 14:49:49 UTC, guiguidu60 wrote:

On Tuesday, 2 July 2019 at 10:43:08 UTC, Andre Pany wrote:

On Tuesday, 2 July 2019 at 08:50:36 UTC, guiguidu60 wrote:

I'm a newbie with D language, and my first problem ever is:

I have a hello world program build with DUB on Linux, but the 
program as marked as "application/x-sharedlib" and not 
"application/x-executable" (in properties of the file): so, I 
can't able to execute the program from the file explorer 
(need to do ./helloworld within a terminal).


Executable is automatically chosen if you have a source code 
file with name "app.d".

Otherwise set targetType to executable in your dub.json.

Kind regards
André


It doesn't work...
Who decide if a file is an application or a sharedlib ?


What file manager are you using?

Could you perhaps upload an example binary that gets detected 
wrong?




Re: DIP 1016 and const ref parameters

2019-06-19 Thread Les De Ridder via Digitalmars-d-learn

On Wednesday, 19 June 2019 at 20:18:58 UTC, Max Haughton wrote:
On Wednesday, 19 June 2019 at 19:25:59 UTC, Jonathan M Davis 
wrote:
On Wednesday, June 19, 2019 12:28:12 PM MDT XavierAP via 
Digitalmars-d-learn wrote:

[...]


The DIPs are here: https://github.com/dlang/DIPs

[...]


DIP1014 has not been implemented in DMD or druntime yet, AFAIK


I have two open PRs for the druntime[1] and Phobos[2] 
implementations,

but no dmd yet.

[1] https://github.com/dlang/druntime/pull/2638
[2] https://github.com/dlang/phobos/pull/7075


Re: Scope exit bug?

2019-06-14 Thread Les De Ridder via Digitalmars-d-learn

On Friday, 14 June 2019 at 05:35:05 UTC, Amex wrote:
I used it to avoid having to write bar twice or use a flag but 
it's not working... I see no reason why it should not work. 
scope(exit) is suppose to execute the block at the end of the 
function call, right?


No, a scope guard executes at the end of the scope. The spec[1] 
has a

few examples (with output).

[1] https://dlang.org/spec/statement.html#scope-guard-statement


Re: [OT] Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-20 Thread Les De Ridder via Digitalmars-d-learn

On Sunday, 19 May 2019 at 12:24:28 UTC, Patrick Schluter wrote:

On Saturday, 18 May 2019 at 21:05:13 UTC, Les De Ridder wrote:
On Saturday, 18 May 2019 at 20:34:33 UTC, Patrick Schluter 
wrote:
* hurrah for French keyboard which has a rarely used µ key, 
but none for Ç a frequent character of the language.





That's the lowercase ç. The uppercase Ç is not directly 
composable,


No, note that I said  and not . Using Lock> it

outputs a 'Ç' for me (at least on X11 with the French layout).



There are 2 other characters that are not available on the 
french keyboard: œ and Œ. Quite annoying if you sell beef 
(bœuf) and eggs (œufs) in the towns of Œutrange or Œting.


It seems those are indeed not on the French layout at all. Might I
suggest using the Belgian layout? It is AZERTY too and has both 
'œ'

and 'Œ'.


Re: 1 - 17 ms, 553 ╬╝s, and 1 hnsec

2019-05-18 Thread Les De Ridder via Digitalmars-d-learn

On Saturday, 18 May 2019 at 20:34:33 UTC, Patrick Schluter wrote:
* hurrah for French keyboard which has a rarely used µ key, but 
none for Ç a frequent character of the language.