Re: Building GUI projects with D

2018-10-21 Thread dangbinghoo via Digitalmars-d-learn

On Saturday, 20 October 2018 at 15:40:07 UTC, karis njiru wrote:
Hi. Am a computer science student from Kenya and decided to use 
D for my class project on Principles of Programming Languages. 
Am having a lot of fun with D but have come across an issue. I 
have been using Visual D for the past 2 months for my coding 
but after a lot of research i found out that i cannot build GUI 
projects with visual D. So i took on Entice Designer which for 
the past week has been a nightmare for me to compile my code 
error being the system cannot find the path in the command 
prompt specified. I have installed DMD and DFL lots of times 
but there is still the same issue. Please help


try GtkD or dlangui(UTF8 support is not complete, font rendering 
is a little bad.) or tkd


Re: assigment to null class object member compiled? is this a bug?

2018-10-21 Thread dangbinghoo via Digitalmars-d-learn

On Friday, 19 October 2018 at 09:08:32 UTC, Vijay Nayar wrote:
Technically the code you have is syntactically correct.  You 
are permitted to create a class variable without assigning it 
to a class object.  (Assigning it to a class object would look 
like "A a = new A();")


Which section of The D Programming Language book makes you 
think this would not compile?  I have the book as well, but I'm 
not quite sure what part of the book you're referring to.


the section 6.2, which is
---
A a;
a.x = 5;
---

the book explained this should be refused to compile.


thanks!

--
dangbinghoo


Re: Can this recursive template type with named type parameters be simplified or improved?

2018-10-21 Thread Hakan Aras via Digitalmars-d-learn

On Sunday, 21 October 2018 at 21:23:35 UTC, aliak wrote:
Hi, I'm playing around with a recursive template type that 
allows for named template parameters. The problem is that it 
requires a lot of repetition and becomes more error prone as 
the number of named arguments increase. So


1) Any ideas on how to make it less error prone? less 
repetition? a better way to do this?
2) Right now I can only have named optional parameters. Any 
ideas on how to make named required parameters (e.g. the first 
type parameter of Type).




I don't know if this is at all helpful, but I spent an hour on 
it, so I'm going to share it:


https://pastebin.com/cGZwc649

You can wrap it in a template if you want to retain the ability 
to pass arguments without names.


Regards,
Hakan



error initializing an immutable struct member with a function that takes a lazy param

2018-10-21 Thread aliak via Digitalmars-d-learn

Hi,

The code below fails with "Error: delegate 
`onlineapp.A!int.A.__dgliteral2` cannot be struct members":


T f(T)(lazy T value) { return value; }

struct A(T) {
immutable a = f("hi");
}

void main() {
A!int i;
}

Removing the lazy keyword fixes the error. But I'm wondering if I 
can keep lazy there. Is this a compile bug perhaps?


The actual use case where this is causing a problem is from this 
function:


https://github.com/aliak00/ddash/blob/5c9f2923028c7c16b89b041b399f6fb1bc73639c/range/source/ddash/range/front.d#L25

and needing to use it in a declaration scope of a struct in this 
kind of way:


struct A(string name) {
  immutable firstPart = name.split("|").frontOr("");
}

Cheers,
-Ali


Can this recursive template type with named type parameters be simplified or improved?

2018-10-21 Thread aliak via Digitalmars-d-learn
Hi, I'm playing around with a recursive template type that allows 
for named template parameters. The problem is that it requires a 
lot of repetition and becomes more error prone as the number of 
named arguments increase. So


1) Any ideas on how to make it less error prone? less repetition? 
a better way to do this?
2) Right now I can only have named optional parameters. Any ideas 
on how to make named required parameters (e.g. the first type 
parameter of Type).


Here's an example of a type that has one required parameter and 4 
optional named parameters:


private struct TypeImpl(
T,
string _arg0 = null,
int _arg1 = 0,
float _arg2 = 0,
alias _arg3 = null,
) {
alias Arg0 = _arg0;
alias Arg1 = _arg1;
alias Arg2 = _arg2;
alias Arg3 = _arg3;
public alias arg0(string value) = TypeImpl!(T, value, Arg1, 
Arg2, Arg3);
public alias arg1(int value) = TypeImpl!(T, Arg0, value, 
Arg2, Arg3);
public alias arg2(float value) = TypeImpl!(T, Arg0, Arg1, 
value, Arg3);

public static template arg3(alias value) {
alias arg3 = TypeImpl!(T, Arg0, Arg1, Arg2, value);
}
}

public template Type(T) {
alias Type = TypeImpl!(T);
}

void main() {
void fun() {}
alias U = Type!int
.arg0!"string"
.arg1!3
.arg3!fun;
pragma(msg, U);
}

Cheers,
- Ali



Re: Which Docker to use?

2018-10-21 Thread Jon Degenhardt via Digitalmars-d-learn

On Sunday, 21 October 2018 at 18:11:37 UTC, Jacob Carlborg wrote:

On 2018-10-18 01:15, Jon Degenhardt wrote:

I need to use docker to build static linked Linux executables. 
My reason
is specific, may be different than the OP's. I'm using 
Travis-CI to
build executables. Travis-CI uses Ubuntu 14.04, but static 
linking fails
on 14.04. The standard C library from Ubuntu 16.04 or later is 
needed.

There may be other/better ways to do this, I don't know.


That's interesting. I've built static binaries for DStep using 
LDC on Travis CI without any problems.


My comment painted too broad a brush. I had forgotten how 
specific the issue I saw was. Apologies for the confusion.


The issue that caused me to go to Ubuntu 16.04 had to do with 
uncaught exceptions when using LTO with the gold linker and LDC 
1.5. Problem occurred with 14.04, but not 16.04. I should go back 
and retest on Ubuntu 14.04 with a more recent LDC, it may well 
have been corrected. The issue thread is here: 
https://github.com/ldc-developers/ldc/issues/2390.


Re: Can opApply be made @nogc?

2018-10-21 Thread welkam via Digitalmars-d-learn

DIP 1000 says:

Delegates currently defensively allocate closures with the GC. 
Few actually escape, and with scope only those that actually 
escape need to have the closures allocated.


https://github.com/dlang/DIPs/blob/master/DIPs/DIP1000.md#benefits


Re: Which Docker to use?

2018-10-21 Thread Jacob Carlborg via Digitalmars-d-learn

On 2018-10-18 01:15, Jon Degenhardt wrote:


I need to use docker to build static linked Linux executables. My reason
is specific, may be different than the OP's. I'm using Travis-CI to
build executables. Travis-CI uses Ubuntu 14.04, but static linking fails
on 14.04. The standard C library from Ubuntu 16.04 or later is needed.
There may be other/better ways to do this, I don't know.


That's interesting. I've built static binaries for DStep using LDC on 
Travis CI without any problems.


--
/Jacob Carlborg


Re: Why is dynamic array length required here?

2018-10-21 Thread Samir via Digitalmars-d-learn
Stanislav, Ali, Mike -- Thank you all for your thoughtful and 
helpful replies to my queries.  Apologies that it has taken this 
long to reply to you.  I still haven't been able to find time to 
go through all of the code examples provided but hope to do so 
later this week.  If I have additional questions, I know where to 
go!


Thanks again!


Re: Building GUI projects with D

2018-10-21 Thread Jacob Carlborg via Digitalmars-d-learn

On 2018-10-20 17:40, karis njiru wrote:

Hi. Am a computer science student from Kenya and decided to use D for my
class project on Principles of Programming Languages. Am having a lot of
fun with D but have come across an issue. I have been using Visual D for
the past 2 months for my coding but after a lot of research i found out
that i cannot build GUI projects with visual D. So i took on Entice
Designer which for the past week has been a nightmare for me to compile
my code error being the system cannot find the path in the command
prompt specified. I have installed DMD and DFL lots of times but there
is still the same issue. Please help


Give DWT [1] a try. It's a port of the Eclipse SWT library from Java to 
D. It's completely written in D and uses the native drawing operations 
of the OS giving the applications a native look and feel.


[1] http://github.com/d-widget-toolkit/dwt

--
/Jacob Carlborg