Re: Where do I learn to use GtkD

2018-10-29 Thread helxi via Digitalmars-d-learn

On Sunday, 13 March 2016 at 19:28:57 UTC, karabuta wrote:
Gtk3 from python3 has got I nice book with examples that are 
not so advanced but enough to get you doing real work(from a 
beginner point of view). GtkD seem to have changed the API 
structure compared to python3 Gtk3 and the demo examples just 
"show-off" IMO :). The documentation is really^ not good :)


Any help on where I can get better leaning materials(GtkD)? 
Repo, blogs post, etc please


Sorry for the shameless self plug, and I know it's already too 
late. I have been working on porting some of the pygtk examples 
to GtkD and covered almost the half of it. For anyone who is 
reading this thread please check out the repo I mention bellow. 
For experienced users of GtkD, please leave your PRs and 
suggestions.



https://gitlab.com/9898287/gtkdnotes



Re: anyway to set a const object after the fact?

2018-10-29 Thread Paul Backus via Digitalmars-d-learn

On Monday, 29 October 2018 at 21:50:32 UTC, aliak wrote:

Hi, so if you have this piece of code:

struct C {

  void f() {
string[] others;
const string[] restArgs;
foreach (i, arg; args) {
  if (isValidArg(arg)) {
restArgs = args[i + 1 .. $];
break;
  }
  others ~= arg;
}
// "others" is a list of args before the valid arg is 
encountered

// "restArgs" is a list that is the args after the valid arg
  }
}

Is there anyway to set a const object after declaring it in the 
above context?


Cheers,
- Ali


Use a lambda:

const string[] restArgs = () {
  foreach(i, arg; args) {
if (isValidArg(arg)) {
  return args[i+1 .. $];
}
others ~= arg;
  }
}();


Re: anyway to set a const object after the fact?

2018-10-29 Thread H. S. Teoh via Digitalmars-d-learn
On Mon, Oct 29, 2018 at 09:50:32PM +, aliak via Digitalmars-d-learn wrote:
> Hi, so if you have this piece of code:
> 
> struct C {
> 
>   void f() {
> string[] others;
> const string[] restArgs;
> foreach (i, arg; args) {
>   if (isValidArg(arg)) {
> restArgs = args[i + 1 .. $];
> break;
>   }
>   others ~= arg;
> }
> // "others" is a list of args before the valid arg is encountered
> // "restArgs" is a list that is the args after the valid arg
>   }
> }
> 
> Is there anyway to set a const object after declaring it in the above
> context?
[...]

What exactly are you trying to accomplish?  I.e., what semantics do you
want from modifying restArgs?

If you're looking to rebind the array, just be a bit more explicit in
how you spell out the type:

const(string)[] restArgs;

will allow you to rebind it to a different array / slice, but still not
permit you to modify the array elements.


T

-- 
Дерево держится корнями, а человек - друзьями.


anyway to set a const object after the fact?

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

Hi, so if you have this piece of code:

struct C {

  void f() {
string[] others;
const string[] restArgs;
foreach (i, arg; args) {
  if (isValidArg(arg)) {
restArgs = args[i + 1 .. $];
break;
  }
  others ~= arg;
}
// "others" is a list of args before the valid arg is 
encountered

// "restArgs" is a list that is the args after the valid arg
  }
}

Is there anyway to set a const object after declaring it in the 
above context?


Cheers,
- Ali



Re: struggling to link against a C global in D (win/vs2017)

2018-10-29 Thread 12345swordy via Digitalmars-d-learn
On Monday, 29 October 2018 at 00:16:38 UTC, Stanislav Blinov 
wrote:

On Monday, 29 October 2018 at 00:01:21 UTC, DanielG wrote:


In my D app I'm declaring it this way:

extern (C) {
extern __gshared int myIntValue;
int myIntFunc (int a, int b);
}

The function seems to link OK, but the C global will not.


Should it be extern(Windows), perchance?.. (I haven't D on 
Windows for ages).


Nope, you use export.


Re: Small or big dub packages

2018-10-29 Thread Laurent Tréguier via Digitalmars-d-learn

On Monday, 29 October 2018 at 11:31:55 UTC, Igor wrote:
Can someone tell me what are pros and cons of having multiple 
extra small dub packages that depend on each other versus one 
dub package that has a bunch of functionality? Good example for 
this is dlib (https://github.com/gecko0307/dlib). It has many 
functionalities that could be split into separate packages.


The way I see it the advantage of smaller packages is that 
users can pick and choose and and only have the code they 
really need in their project, but the con could become managing 
a lot of dependencies. Also I am not sure how compile time on 
clean project and previously compiled project would be affected.


I'd use subpackages in such cases. This way you can either have 
one dependency on the whole thing, or select only a few 
subpackages.


Small or big dub packages

2018-10-29 Thread Igor via Digitalmars-d-learn
Can someone tell me what are pros and cons of having multiple 
extra small dub packages that depend on each other versus one dub 
package that has a bunch of functionality? Good example for this 
is dlib (https://github.com/gecko0307/dlib). It has many 
functionalities that could be split into separate packages.


The way I see it the advantage of smaller packages is that users 
can pick and choose and and only have the code they really need 
in their project, but the con could become managing a lot of 
dependencies. Also I am not sure how compile time on clean 
project and previously compiled project would be affected.


Profiling with DUB?

2018-10-29 Thread Dukc via Digitalmars-d-learn

I'm trying to profile my program, built like:

dub build --build=profile

When I run the program, where is the performance profile file 
supposed to appear? I can find nothing new in the program/project 
root directory. This happens regardless whether I compile with 
dmd or ldc2.