Re: Anonymous structure

2016-04-18 Thread captaindet via Digitalmars-d-learn

On 2016-04-18 14:12, Tofu Ninja wrote:

Also is there a way to have a named substructure, not a nested structure
but something to just add an additional name, maybe something like
struct a{
 struct{
 int x;
 int y;
 int z;
 } b;
}


not sure what you mean by "named substructure, not a nested structure" 
but this works:


struct Outer{
struct Inner{
int x;
int y;
int z;
}
Inner inner;
int a;
}

Outer outer;
outer.a = 7;
outer.inner.y = 42;
//  outer.x = 13; //fails

writeln(outer);



Re: Using D in Android App

2016-04-18 Thread Laeeth Isharc via Digitalmars-d-learn

On Saturday, 16 April 2016 at 04:04:24 UTC, Justice wrote:
Is it difficult to create a D business like app and connect it 
to android through java for the interface?


I'd rather create all the complex stuff in D and either use it 
natively through java(I need a UI).


If it is workable, can the same be said for IOS(just recompile 
the D source to the IOS architecture then use it in an IOS app 
for the ui)?



Depending on your budget, you could also look at Corona - Lua can 
call D easily.


I haven't used on Android, but Qt QML may be worth a look (D 
bindings to QML).



Wrt to D on android I would try porting some existing code and 
see how that goes.  I think stuff seemed to work but because you 
don't yet have so much company then it may be hard to be sure you 
might not hit some problems till you try.


Re: Question about dub and imports

2016-04-18 Thread Jonathan Villa via Digitalmars-d-learn

On Monday, 18 April 2016 at 21:23:02 UTC, Jonathan Villa wrote:
I'm trying to build a vibe.d application, but I made a little 
library (just source code) that I want to add to the project.


[...]


Close the question,

looks like I found it: importPaths.



Question about dub and imports

2016-04-18 Thread Jonathan Villa via Digitalmars-d-learn
I'm trying to build a vibe.d application, but I made a little 
library (just source code) that I want to add to the project.


So, in the generated dub.sdl file I added at the end:
sourcePaths "../D/src"
sourceFiles "../D/src/alfred/package.d"

The problem is at build time DUB tries to create a library file 
and it fails.
I don't want to it to create a .lib file, just "look at this path 
so when I write `import alfred;` you know where this refers to`.


I'm pretty new using the dub thing, I have look in 
https://code.dlang.org/package-format?lang=sdl but I get a little 
confused.


I have already did this in a non-dub project, adding the import 
path with -I and listing the files and it never actually 
generated a lib.


Or is there a way to just inject a direct line to the build 
params like "-I../D/src" alfred/types.d alfred/command.d ...(etc) 
when running dub in my vibe-d project???


(Is really neccesary to look my little source library like a .lib 
file and try to generate it?)


JV


Re: Is there a way to disable 'dub test' for applications?

2016-04-18 Thread Dicebot via Digitalmars-d-learn

On Monday, 18 April 2016 at 18:19:32 UTC, Jon D wrote:

On Monday, 18 April 2016 at 11:47:42 UTC, Dicebot wrote:

On Monday, 18 April 2016 at 04:25:25 UTC, Jon D wrote:
I have an dub config file specifying a targetType of 
'executable'. There is only one file, the file containing 
main(), and no unit tests.


When I run 'dub test', dub builds and runs the executable. 
This is not really desirable. Is there a way to set up the 
dub configuration file to disable running the test?


configuration "unittest" {
excludedSourceFiles "path/to/main.d"
}


Very nice, thank you. What also seems to work is:
configuration "unittest" {
targetType "none"
}

Then 'dub test' produces the message:
Configuration 'unittest' has target type "none". Skipping 
test.


Those two option do different things. My proposal excludes file 
with `main` function from tested sources but keeps actual test 
target (so if you have unittest blocks in other modules, those 
will be checked). Your version completely disabled test target.


I wasn't sure which option you want but glad it helped.


Re: Is there a way to disable 'dub test' for applications?

2016-04-18 Thread Jon D via Digitalmars-d-learn

On Monday, 18 April 2016 at 11:47:42 UTC, Dicebot wrote:

On Monday, 18 April 2016 at 04:25:25 UTC, Jon D wrote:
I have an dub config file specifying a targetType of 
'executable'. There is only one file, the file containing 
main(), and no unit tests.


When I run 'dub test', dub builds and runs the executable. 
This is not really desirable. Is there a way to set up the dub 
configuration file to disable running the test?


configuration "unittest" {
excludedSourceFiles "path/to/main.d"
}


Very nice, thank you. What also seems to work is:
configuration "unittest" {
targetType "none"
}

Then 'dub test' produces the message:
Configuration 'unittest' has target type "none". Skipping 
test.






Re: Using D in Android App

2016-04-18 Thread Dan Olson via Digitalmars-d-learn
Justice  writes:

> On Saturday, 16 April 2016 at 04:04:24 UTC, Justice wrote:
>> Is it difficult to create a D business like app and connect it to
>> android through java for the interface?
>>
>> I'd rather create all the complex stuff in D and either use it
>> natively through java(I need a UI).
>>
>> If it is workable, can the same be said for IOS(just recompile the D
>> source to the IOS architecture then use it in an IOS app for the
>> ui)?
>
> Anyone?

Short answer is it should work: see "Alpha support for mobile" links on
http://dlang.org/download.html

Joakim has been pushing Android support and I've been working on getting
iOS into the core language.  The caveat is that both are alpha support
and it is hard to predict when they will be first class D citizens.

Speaking for the iOS support, the downloadable compiler is based on
2.068 (LDC 0.17.0) and will move to whatever LDC supports after 1.0.0 is
released.  I don't know of any problems at this stage, as long as you
just want to side load your app.  Submitting to the App Store is another
matter.  It has not been done yet and Apple's requirement to include
embedded bitcode is missing currently.
-- 
Dan


Re: Anonymous structure

2016-04-18 Thread Steven Schveighoffer via Digitalmars-d-learn

On 4/17/16 11:57 PM, Tofu Ninja wrote:

On Monday, 18 April 2016 at 03:33:53 UTC, Adam D. Ruppe wrote:

The struct inside union is the main pure-language use case I know of
though.


Actually curiously I found another potential use, applying
attributes/UDAs to multiple members at once.

enum testUDA;
struct T{
 @testUDA
 immutable struct{
 int x;
 int y;
 int z;
 }
}

x,y,and z seem to all be immutable and all have the UDA testUDA. But
even odder, it seems that "struct" in there is doing absolutely nothing.
The same thing can be done with

enum testUDA;
struct T{
 @testUDA
 immutable{
 int x;
 int y;
 int z;
 }
}

So it still seems to be useless other than in the case of unions...


I wonder if it makes a difference for layout. So for example:

struct T
{
   struct
   {
  int x;
  ubyte y;
   }
   ubyte z;
}

If there is padding inserted between y and z.

-Steve


Re: multithreading profiling

2016-04-18 Thread tcak via Digitalmars-d-learn

On Monday, 18 April 2016 at 13:33:20 UTC, jj75607 wrote:

Hello!

Is it possible to start profiling on multithreaded app with Dmd?

https://issues.dlang.org/show_bug.cgi?id=14511 is open. I am 
doing wrong or why this program segfaults if compiled with 
profiler hooks?


import core.atomic;

shared struct S
{   
uint counter;

bool inc() shared
{
atomicOp!("+=")(counter, 1);
return true;
}
}

int main(string[] argv)
{
S s;

return 0;
}

Thank you!


As far as I know, profiling system doesn't work on multithreading 
programs correctly. At least, it has never worked for me. While 
closing the program, it creates problem always. But in a signle 
threaded environment, no problem.


Re: Which application is much suited and which is not.

2016-04-18 Thread Gerald via Digitalmars-d-learn

On Saturday, 16 April 2016 at 14:08:05 UTC, newB wrote:
Let's say you have decided to use D programming language. For 
what kind of applications would you choose D programming 
language and For what kind of applications you won't choose D 
programming.


I might be in the minority opinion here but personally I wouldn't 
use D for enterprise applications in a Fortune 500 type 
environment unless there was a significant order of magnitude 
advantage to doing so (i.e. some niche that D really shines in 
compared to Java/C#). I'd say this for the following reasons:


a. Eco-system. D is a great language but it's eco-system of 
libraries is very weak compared to more mature stacks, 
integration in a heterogeneous enterprise environment is not 
going to be D's forte.


b. Talent availability. Java/C# developers are easy to find, D 
not so much


Re: multithreading profiling

2016-04-18 Thread jj75607 via Digitalmars-d-learn

On Monday, 18 April 2016 at 13:45:20 UTC, Marc Schütz wrote:

Which platform/OS, dmd version, and command line are you using?


Windows7, DMD 2.071.0, run from Visual Studio 2013 Community + 
VisualD 0.3.43


Re: multithreading profiling

2016-04-18 Thread Marc Schütz via Digitalmars-d-learn

Which platform/OS, dmd version, and command line are you using?


multithreading profiling

2016-04-18 Thread jj75607 via Digitalmars-d-learn

Hello!

Is it possible to start profiling on multithreaded app with Dmd?

https://issues.dlang.org/show_bug.cgi?id=14511 is open. I am 
doing wrong or why this program segfaults if compiled with 
profiler hooks?


import core.atomic;

shared struct S
{   
uint counter;

bool inc() shared
{
atomicOp!("+=")(counter, 1);
return true;
}
}

int main(string[] argv)
{
S s;

return 0;
}

Thank you!


Re: Using D in Android App

2016-04-18 Thread Michael via Digitalmars-d-learn

On Monday, 18 April 2016 at 09:38:48 UTC, Justice wrote:

On Saturday, 16 April 2016 at 04:04:24 UTC, Justice wrote:
Is it difficult to create a D business like app and connect it 
to android through java for the interface?


I'd rather create all the complex stuff in D and either use it 
natively through java(I need a UI).


If it is workable, can the same be said for IOS(just recompile 
the D source to the IOS architecture then use it in an IOS app 
for the ui)?


Anyone?


If you're treating the Android/iOS applications as purely 
"client-side", then there's no reason why you can't create a 
"server-side" application in D using something like vibe.d and 
then passing data between clients and servers using JSON or 
similar data interchange formats. That way,you only develop the 
main server-side application in D, and can communicate with it 
using any other language (Java/C#/Swift) on other operating 
systems and devices.


Re: Is there a way to disable 'dub test' for applications?

2016-04-18 Thread Dicebot via Digitalmars-d-learn

On Monday, 18 April 2016 at 04:25:25 UTC, Jon D wrote:
I have an dub config file specifying a targetType of 
'executable'. There is only one file, the file containing 
main(), and no unit tests.


When I run 'dub test', dub builds and runs the executable. This 
is not really desirable. Is there a way to set up the dub 
configuration file to disable running the test?


configuration "unittest" {
excludedSourceFiles "path/to/main.d"
}


Re: Is there a way to disable 'dub test' for applications?

2016-04-18 Thread Kagamin via Digitalmars-d-learn

You can write it in code:
version(unittest)
  static assert(false,"unit tests not supported");


Re: Using D in Android App

2016-04-18 Thread Justice via Digitalmars-d-learn

On Saturday, 16 April 2016 at 04:04:24 UTC, Justice wrote:
Is it difficult to create a D business like app and connect it 
to android through java for the interface?


I'd rather create all the complex stuff in D and either use it 
natively through java(I need a UI).


If it is workable, can the same be said for IOS(just recompile 
the D source to the IOS architecture then use it in an IOS app 
for the ui)?


Anyone?



Re: Dlang UI - making widget extend to the bounds of the window

2016-04-18 Thread Vadim Lopatin via Digitalmars-d-learn

On Monday, 18 April 2016 at 07:06:43 UTC, Vadim Lopatin wrote:
In TableLayout there is a bug #113 which prevents extending of 
table layout content to parent size.


For other widgets FILL_PARENT should work ok.


Issue #113 is fixed today in v0.8.8



Re: Dlang UI - making widget extend to the bounds of the window

2016-04-18 Thread Vadim Lopatin via Digitalmars-d-learn

On Saturday, 16 April 2016 at 11:46:09 UTC, stunaep wrote:

On Saturday, 16 April 2016 at 08:20:33 UTC, stunaep wrote:

On Friday, 15 April 2016 at 10:33:35 UTC, Vadim Lopatin wrote:

[...]


I am doing that. I think it has to do with my high dpi because 
I'm using a 4k monitor.


If I use Modal window flag:

[...]

http://i.imgur.com/FJgPq8U.png

If I use resizable:

[...]

http://i.imgur.com/PsPwoSN.jpg


Actually, that is with the opengl area set to a specific size. 
Here is using fill:


Window window = Platform.instance.createWindow("DlangUI OpenGL 
Example", null, WindowFlag.Modal, 1250, 1250);

http://i.imgur.com/exAyjI0.png

   Window window = Platform.instance.createWindow("DlangUI 
OpenGL Example", null, WindowFlag.Resizable, 1250, 1250);

http://i.imgur.com/R7oxBa0.jpg

http://pastebin.com/qqbfQLvN


In TableLayout there is a bug #113 which prevents extending of 
table layout content to parent size.


For other widgets FILL_PARENT should work ok.

See dlangui/examples/d3d and dlangui/examples/opengl for samples 
of OpenGL drawing on widget which is being resized to whole 
window.