Re: Creating fixed array on stack

2019-01-12 Thread Andrey via Digitalmars-d-learn

On Friday, 11 January 2019 at 15:23:08 UTC, Dgame wrote:

On Friday, 11 January 2019 at 14:46:36 UTC, Andrey wrote:

Hi,
In C++ you can create a fixed array on stack:

int count = getCount();
int myarray[count];


In D the "count" is part of type and must be known at CT but 
in example it is RT.

How to do such thing in D? Without using of heap.


You could try alloca:


import core.stdc.stdlib: alloca;

pragma(inline, true) auto stack(T, alias len)(void* p = 
alloca(T.sizeof * len)) {

return (cast(T*) p)[0 .. len] = T.init;
}

void main() {
import std.stdio: writeln;

int size = 42;
auto a = stack!(int, size);
writeln(a);
a[] = 2;
writeln(a);
}



Thank you.
But this requires using of C function "alloca". I think this 
cause some RT overhead (and in output asm code) in comparison 
with C++ variant. Or I'm not right?


Re: Has anyone tried making a QtCreator plugin for D and what is your experience?

2019-01-12 Thread Laurent Tréguier via Digitalmars-d-learn

On Friday, 11 January 2019 at 18:52:14 UTC, Enjoys Math wrote:
I'm 5 years an expert at PyQt5 in conjunction with 
QtCreator-designed widgets.  Where D is lacking is a good GUI 
editor and GUI library support.


I am starting by building a python-based project called QDmt = 
Qt/D manager


It will do for you, in a cross-platform way, the laborious task 
of compiling the Qt framework from git:


https://wiki.qt.io/Building_Qt_5_from_Git

And also it will guide you through building Qt Creator itself.  
We can then use this tool to help us hack the Qt Creator code 
and make it work for D (assuming a plugin isn't enough).


Building Qt is quite essential, as I am unable to get OpenGL 
support without building it for example.


So not only will we get traffic from TDPL people but from 
others who are only familiar with Qt and had to build it for 
some reason.  This would then be the goto tool for that.


Then they will see firsthand how easy it is (at the click of a 
few buttons) to work with D.


This will cause a huge influx of users to dlang.org and a rift 
in the spacetime continuum!


QtCreator 4.8.0 introduced support for the LSP last month : 
https://blog.qt.io/blog/2018/12/06/qt-creator-4-8-0-released


I think I'm going to add it to the list of editors to look into 
and perhaps try to make a plugin for it.


Re: Creating fixed array on stack

2019-01-12 Thread Adam D. Ruppe via Digitalmars-d-learn

On Saturday, 12 January 2019 at 08:10:47 UTC, Andrey wrote:
But this requires using of C function "alloca". I think this 
cause some RT overhead (and in output asm code) in comparison 
with C++ variant. Or I'm not right?


alloca is a magical function; a compiler intrinsic that works the 
same way as the C built-in.


Re: nice-curses releases / dub version git?

2019-01-12 Thread 0xEAB via Digitalmars-d-learn

On Saturday, 12 January 2019 at 12:10:25 UTC, Droggl wrote:
2. Is there a way to get a certain git-version (eg. commit or 
maybe even just "latest") for a package in dub?


JSON: "nice-curses": "~master"
SDL: dependency "nice-curses" version="~master"


3. How is everyone in general using curses with D? Is there 
maybe a different library I should checkout instead?


I usually use arsd.terminal instead.


 - Elias


Re: Coedit almost works for me, except when I go to add peggged

2019-01-12 Thread 0xEAB via Digitalmars-d-learn

On Friday, 11 January 2019 at 18:40:08 UTC, Enjoys Math wrote:
You will have to be more specific.  I don't see dub.json 
anywhere within Coedit IDE.


are you using DUB or not?


Re: Has anyone tried making a QtCreator plugin for D and what is your experience?

2019-01-12 Thread Laurent Tréguier via Digitalmars-d-learn
On Saturday, 12 January 2019 at 15:16:25 UTC, Laurent Tréguier 
wrote:
QtCreator 4.8.0 introduced support for the LSP last month : 
https://blog.qt.io/blog/2018/12/06/qt-creator-4-8-0-released


I think I'm going to add it to the list of editors to look into 
and perhaps try to make a plugin for it.


Correction: a language server can simply be set up in the LSP 
plugin's options after the plugin has been enabled, so some 
amount of D support is achievable already.


nice-curses releases / dub version git?

2019-01-12 Thread Droggl via Digitalmars-d-learn

Hey there D community!
After a a bunch of years absence I'm getting back into D and its 
quite fun so far :-)


I'm working on a little project that is uses nice-curses and now 
I stumbled across a bug that makes building impossible on Windows 
for me. Luckily that was fixed 3 months ago, but the last 
nice-curses release is from 2017 :-(


So here are my questions:

1. Are there any plans in terms of future releases of nice-curses?
2. Is there a way to get a certain git-version (eg. commit or 
maybe even just "latest") for a package in dub?
3. How is everyone in general using curses with D? Is there maybe 
a different library I should checkout instead? Are you using 
latest git?


Best regards,
Droggl


Re: nice-curses releases / dub version git?

2019-01-12 Thread Neia Neutuladh via Digitalmars-d-learn
On Sat, 12 Jan 2019 12:10:25 +, Droggl wrote:
> 2. Is there a way to get a certain git-version (eg. commit or maybe even
> just "latest") for a package in dub?

git submodule and path-based dependencies, if you need a particular 
version.

> 3. How is everyone in general using curses with D? Is there maybe a
> different library I should checkout instead? Are you using latest git?

dstep on curses.h and including that directly in my project.


Re: nice-curses releases / dub version git?

2019-01-12 Thread H. S. Teoh via Digitalmars-d-learn
On Sat, Jan 12, 2019 at 05:38:09PM +, Neia Neutuladh via 
Digitalmars-d-learn wrote:
> On Sat, 12 Jan 2019 12:10:25 +, Droggl wrote:
[...]
> > 3. How is everyone in general using curses with D? Is there maybe a
> > different library I should checkout instead? Are you using latest
> > git?
[...]

I tried using (n)curses in D before, but eventually opted for a
D-specific solution: Adam Ruppe's terminal.d:

https://github.com/adamdruppe/arsd/blob/master/terminal.d

Fits much better with idiomatic D, and has served me very well since.


T

-- 
What doesn't kill me makes me stranger.


Re: Has anyone tried making a QtCreator plugin for D and what is your experience?

2019-01-12 Thread Enjoys Math via Digitalmars-d-learn
On Saturday, 12 January 2019 at 16:09:22 UTC, Laurent Tréguier 
wrote:
On Saturday, 12 January 2019 at 15:16:25 UTC, Laurent Tréguier 
wrote:
QtCreator 4.8.0 introduced support for the LSP last month : 
https://blog.qt.io/blog/2018/12/06/qt-creator-4-8-0-released


I think I'm going to add it to the list of editors to look 
into and perhaps try to make a plugin for it.


Correction: a language server can simply be set up in the LSP 
plugin's options after the plugin has been enabled, so some 
amount of D support is achievable already.


I see your links. Would you like to work on this together?  
Social coding is more powerful than solo coding IMO.


Re: Reversing a string

2019-01-12 Thread Seb via Digitalmars-d-learn

On Friday, 11 January 2019 at 19:16:05 UTC, AlCaponeJr wrote:

On Friday, 11 January 2019 at 11:15:05 UTC, Mike James wrote:

Check out the origin :-)

https://forum.dlang.org/thread/hl8345$2b1q$1...@digitalmars.com?page=1


Indeed a terrible name, please don't tell me this was chosen by 
vote.


By the way currently is there any vote system for naming these 
things?


Al.


No. There are zero plans to break a ton of code by changing the 
name of a symbol in the standard library.


It's more likely that someone comes along with a new general 
purpose library which hasn't seen much usage and thus can define 
slightly better names.


Re: Creating fixed array on stack

2019-01-12 Thread Seb via Digitalmars-d-learn

On Saturday, 12 January 2019 at 13:17:00 UTC, Adam D. Ruppe wrote:

On Saturday, 12 January 2019 at 08:10:47 UTC, Andrey wrote:
But this requires using of C function "alloca". I think this 
cause some RT overhead (and in output asm code) in comparison 
with C++ variant. Or I'm not right?


alloca is a magical function; a compiler intrinsic that works 
the same way as the C built-in.


Yup, specifically (at least for DMD) it is defined here:

https://github.com/dlang/druntime/blob/master/src/rt/alloca.d